Re: float32, float64?
- Posted by "Boehme, Gabriel" <gboehme at POSTOFFICE.MUSICLAND.COM> Nov 19, 1999
- 495 views
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 ---------- To have a horror of tobacco is not to have an abstract standard of right; but exactly the opposite. It is to have no standard of right whatever; and to take certain local likes and dislikes as a substitute. G.K. Chesterton ----------