1. float32, float64?

My request is simple.  Improve the type below.
I don't think I should have to convert the value to a float32
sequence and back just to see if the stored value is accurate.

    I know that float64 is as accurate as I can get.  I don't
want to store numbers as float64 if I can accurately store
them as float32.

  Thanks in advanced for your assistance.

type float32(atom a)
  return (a = float32_to_atom(atom_to_float32(a)))
end type

        Lucius L. Hilley III
        lhilley at cdc.net   lucius at ComputerCafeUSA.com
+----------+--------------+--------------+----------+
| Hollow   | ICQ: 9638898 | AIM: LLHIII  | Computer |
|  Horse   +--------------+--------------+  Cafe'   |
| Software | http://www.cdc.net/~lhilley |  USA     |
+----------+-------+---------------------+----------+
                   | http://www.ComputerCafeUSA.com |
                   +--------------------------------+

new topic     » topic index » view message » categorize

2. Re: float32, float64?

On Fri, 19 Nov 1999 12:51:05 -0500, Lucius L. Hilley III <lhilley at CDC.NET>
wrote:

>    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
--

   Bernie

new topic     » goto parent     » topic index » view message » categorize

3. Re: float32, float64?

> ---------------------- Information from the mail
header -----------------------
> Sender:       Euphoria Programming for MS-DOS
<EUPHORIA at LISTSERV.MUOHIO.EDU>
> Poster:       Bernie Ryan <bwryan at PCOM.NET>
> Subject:      Re: float32, float64?
> --------------------------------------------------------------------------
-----
>
> On Fri, 19 Nov 1999 12:51:05 -0500, Lucius L. Hilley III <lhilley at CDC.NET>
> wrote:
>
> >    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
> --
>
>    Bernie
>

    I can now. :)  Thank you.  I didn't know the exact values.
I figured at least 1 of about 200 minds would know.

        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 message » categorize

4. 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

----------
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
----------

new topic     » goto parent     » topic index » view message » categorize

5. Re: float32, float64?

On Fri, 19 Nov 1999 16:46:52 -0600, Boehme, Gabriel
<gboehme at POSTOFFICE.MUSICLAND.COM> wrote:

>Sorry, but that won't work. Why not? Because whether an atom is float32 or

Gabriel :
   I don't use these to test atoms. The idea of type define is to prevent
   a variable from accepting a value that is within a given range. I use
   them as a new user defined variable types.

float var1
double var2

var1 = 3.4
var2 = 33.25677

Bernie

new topic     » goto parent     » topic index » view message » categorize

6. Re: float32, float64?

Bernie Ryan responded:
> I don't use these to test atoms. The idea of type define is to prevent
> a variable from accepting a value that is within a given range. I use
> them as a new user defined variable types.

That's perfectly fine. However, look closely at what Lucius asked for in his
original post:

Lucius originally wrote:
>I don't think I should have to convert the value to a float32
>sequence and back just to see if the stored value is accurate.
>
>    I know that float64 is as accurate as I can get.  I don't
>want to store numbers as float64 if I can accurately store
>them as float32.

Notice how the word "accurate" is stressed. My interpretation of this was
that he wanted a check for the most *accurate* machine type, not simply the
general numeric ranges. If my impression is wrong, I apologize, but I wanted
to be sure that his concerns about accuracy were addressed.


Hep yadda,
Gabriel Boehme

----------
Reason is always a kind of brute force; those who appeal to the head rather
than the heart, however pallid and polite, are necessarily men of violence.
We speak of "touching" a man's heart, but we can do nothing to his head but
hit it.

G.K. Chesterton
----------

new topic     » goto parent     » topic index » view message » categorize

7. Re: float32, float64?

> ---------------------- 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 message » categorize

8. Re: float32, float64?

> My request is simple.  Improve the type below.
> I don't think I should have to convert the value to a float32
> sequence and back just to see if the stored value is accurate.

Hmm, maybe by adding the lowest possible value with a float32 and adding the
highest
possible value. If adding such a low value makes any difference, and adding
adding such a
high value, then the value can be stored in 32 bit. I'm not sure though, this is
just a guess.




Ralf Nieuwenhuijsen

[[ Email ]]
    nieuwen at xs4all.nl
    ralf_n at email.com

[[ I-Seek-You ]]
   UIN: 9389920

[[ The Elevator ]]
    http://www.xs4all.nl/~nieuwen



Download NeoPlanet at http://www.neoplanet.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu