comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: converting floats to doubles
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: converting floats to doubles [message #44194 is a reply to message #44103] Sun, 22 May 2005 16:01 Go to previous message
Peter Mason is currently offline  Peter Mason
Messages: 145
Registered: June 1996
Senior Member
Benjamin Hornberger wrote:
<...>
> Actually I meant dindgen(n) vs. double(findgen(n)) in the first
> place. I always mix them up ... But I think I got the point.

Hi Benjamin,

A single-precision float (as in findgen()) has a mantissa that's effectively
24 bits. Consequentially it represents every integer in the range
[-16777215, 16777215] *exactly*. So if your "n" in "findgen(n)" is smaller
than 1677216, it doesn't matter whether you use double(findgen(n)) or
dindgen(n).
For bigger "n", you will start getting repeat values if you use
double(findgen(n)) as the float mantissa will have run out of bits and the
double conversion happens after the fact. Here, dindgen() is better. The
double mantissa is much bigger (effectively 53 bits) so dindgen ~should~
only start hitting repeats for "n" >= 2^53. (I can't actually check if the
algorithm within dindgen() behaves properly outside the 32-bit unsigned
integer range. Dindgen(2LL^32LL) alone would be a 32GB array! :-))

Peter Mason
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ascii-template
Next Topic: Re: Catch the area outside a contour

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 11:18:47 PDT 2025

Total time taken to generate the page: 0.64067 seconds