Re: power overflow
- Posted by "Carl W." <euphoria at cyreksoft.yorks.com> Jun 05, 2002
- 424 views
a.tammer at hetnet.nl wrote: > There's one way, to solve the problems on this issue, I guess. > If you use 'Anomaly' as Carl White calls it, it's an FPvalue, > and a strange one too, it's 0 AND ! 0 > I think Carl will allow me to give you it's exact specs. I called it 'Anomaly' before I looked into what value it actually represents, because it really is an anomalous number in the way that Euphoria handles it. [Note that some other languages have the similar problems] A better name for 'Anomaly' would be something like 'float64_minimum' or 'tiniest_atom' since it's true value is power(2, -1074). Surprisingly, the power() function actually generates it: constant X = power(2, -1073), -- Anomaly-like, but not the smallest possible. Anomaly = power(2, -1074), -- Smallest representable IEEE-64bit atom. Y = power(2, -1075), -- Too small to represent. Zero = 0 ? X -- prints 0 ? X = Zero -- prints 0, so it *looks*like* X = 0 and != 0 ? Anomaly -- prints 0 ? Anomaly = Zero -- prints 0, so it *looks*like* Anomaly = 0 and != 0 ? Y -- prints 0 ? Y = Zero -- prints 1 - Too small so is identical to 0. Also, if you try dividing by Anomaly (or 'X'), you'll get a 'Divide by Zero' error even though Anomaly is really greater than Zero. This is down to the fact that 1/power(2,-1074) = power(2,1074) which is too big to fit in an atom or a float64. > Specs 'Anomaly': FP64 63 0binary positions, last position = 1 > last= LSD [not the dope, dope-heads ] I was going to suggest using float64_to_atom({0,0,0,0,0,0,0,1}) [or is that float64_to_atom({1,0,0,0,0,0,0,0})?], but using power() doesn't require an include and it's easier to remember which way round to put the numbers. ;) Carl -- [ Carl R White -=- aka -=- Cyrek the Illogical ] [ () E-mail...: cyrek{}cyreksoft.yorks.com ] [ /\ URL......: http://www.cyreksoft.yorks.com ]