delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/05/19:14:17

From: nikki AT gameboutique DOT co (nikki)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: floats v doubles myth
Date: 5 Feb 1997 14:47:49 GMT
Organization: GameBoutique Ltd.
Lines: 35
Message-ID: <5da6il$gb5@flex.uunet.pipex.com>
References: <32f2a072 DOT 17736424 AT news DOT ionsys DOT com>
<32f3a643 DOT 25054189 AT news DOT ox DOT ac DOT uk> <Jyj5XLAaMk9yEwb1 AT foobar DOT co DOT uk>
<32F7CE6F DOT 16DF AT pobox DOT oleane DOT com>
NNTP-Posting-Host: www.gameboutique.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

> Myth ? which myth? This is true.
> Try this : 
> 
> On my 486dx75, this program prints "20 12", which means the calculation 
> in floats is about twice slower than the calculation in doubles.
> 
> As you can see, there are no fancy functions with prototypes in doubles 
> involved, just plain multiplies and adds...

i had to test this one out. couldn't pass up on it ;)
on my p150 your program gave 11 4
pretty good eh? proves your point too. so you must be right.
so then i took the code between the first timer and swapped it with that
between the second timer..
i got..

11 4

:) what you forgot was that gcc had beautifully organised your code to
keep the values from the first part and reuse them in the second part rather
than reload them. so the second timer will always be faster in your code :)
looks like gcc outwitted you and the myth ;)
what you could do is produce the same with inline assembler and the volatile
statement, and *then* see what you get for the timings. but as leathal says,
you'll find theres no difference in speed on a pentium.
having said that, watch out for 80bit floating point stuff on a pentium
as that does have some drawbacks (like being slower and np with loading/
storing)

regards,
nik

-- 
Graham Tootell           
nikki AT gameboutique DOT com  

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019