1. Re: abs function
- Posted by "Lucius L. Hilley III" <lhilley at CDC.NET>
Jul 10, 1999
-
Last edited Jul 11, 1999
Only one problem? There is yet another problem.
Say that an atoms range is from 0 to 255.
I know this isn't true but just keep the fact that
there IS a limit much higher involved.
If 255 is your limit and you want the abs() of 16
then you will have already went beyond your limit.
16*16 = 256 and is > 255 which is the stated hypothetical
range limit.
In short. this abs() will only work for numbers equal to
or less than sqrt(atom_max_value).
Lucius L. Hilley III
lhilley at cdc.net
+----------+--------------+--------------+
| Hollow | ICQ: 9638898 | AIM: LLHIII |
| Horse +--------------+--------------+
| Software | http://www.cdc.net/~lhilley |
+----------+-----------------------------+
----- Original Message -----
From: Derek Brown <Cyrusbrown at AOL.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Saturday, July 10, 1999 9:19 AM
Subject: Re: abs function
> ---------------------- Information from the mail
header -----------------------
> Sender: Euphoria Programming for MS-DOS
<EUPHORIA at LISTSERV.MUOHIO.EDU>
> Poster: Derek Brown <Cyrusbrown at AOL.COM>
> Subject: Re: abs function
> --------------------------------------------------------------------------
-----
>
> That's a pretty short way of doing it, but there is only one problem.
When
> using atoms, finding the square and the square root of a number with lots
of
> decimal places will cause it to lose accuracy. But, for integers, that
way
> is good.
> This will keep the accuracy by only changing the sign if necessary:
>
> global function abs(atom x)
> if x < 0 then return 0 - x else return x end if
> end function
>
> Derek Brown
>