Re: float32, float64?

new topic     » goto parent     » topic index » view thread      » older message » newer message

> ---------------------- Information from the mail
header -----------------------
> Sender:       Euphoria Programming for MS-DOS
<EUPHORIA at LISTSERV.MUOHIO.EDU>
> Poster:       "Boehme, Gabriel" <gboehme at POSTOFFICE.MUSICLAND.COM>
> Subject:      Re: float32, float64?
> --------------------------------------------------------------------------
-----
>
> Bernie Ryan wrote (in response to Lucius L. Hilley):
>
> >>    My request is simple.  Improve the type below.
> >
> >  Lucius: Can't you do this ?
> >
> >--
> >global
> >type float( atom val)
> >  if ( val >= -3.4E38 and val <= 3.4E38 ) then return 1 else return 0 end
> if
> >end type
> >--
> >--
> >global
> >type double( atom val)
> >  if ( val >= -1.7E308 and val <= 1.7E308 ) then return 1 else return 0
end
> >if
> >end type
> >--
>
> Sorry, but that won't work. Why not? Because whether an atom is float32 or
> float64 is not dependent on the range of values alone, but also upon its
> decimal accuracy. The value of 1/7 CANNOT be accurately represented with a
> float32 -- to get the most accurate representation, you MUST use a
float64.
>
> -- begin example code
> constant a = 1/7
> ? (a = float32_to_atom(atom_to_float32(a))) -- prints 0 (FALSE)
> -- end example code
>
> As far as I know, Lucius, your original method is the only 100% accurate
> method for determining what machine type an atom really is.
>
>
> Hep yadda,
> Gabriel Boehme

    I need 100% accuracy.  If the range test isn't 100% accurate then I will
have to resort to the back and forth equivalence test.

        Lucius L. Hilley III
        lhilley at cdc.net
+----------+--------------+--------------+
| Hollow   | ICQ: 9638898 | AIM: LLHIII  |
|  Horse   +--------------+--------------+
| Software | http://www.cdc.net/~lhilley |
+----------+-----------------------------+

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu