Pages: « 1 2 3 4
  Print  
Author Topic: Fixed those Makefiles  (Read 36178 times)
Offline (Male) Rusky
Reply #45 Posted on: May 19, 2010, 07:34:49 pm

Resident Troll
Joined: Feb 2008
Posts: 954
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
yay floating point
Logged
Offline (Unknown gender) freezway
Reply #46 Posted on: May 19, 2010, 07:58:38 pm

Member
Joined: Dec 2009
Posts: 220

View Profile
i can make my calc say 1*5 = 5.000000001 b/c it keeps 14 digits of precision but displays 9
Logged
if you drop a cat with buttered toast strapped to its back, which side lands down?
joshdreamland: our languages are based on the idea that it's going to end up FUBAR
/kick retep998
Offline (Male) retep998
Reply #47 Posted on: May 19, 2010, 08:15:15 pm

Member
Location: Where else?
Joined: Jan 2010
Posts: 248
MSN Messenger - retep998@charter.net AOL Instant Messenger - retep998 Yahoo Instant Messenger - retep998
View Profile Email
My calc store integers and fractions as bignum and boy can they get big.
Around 2 to the 2200 power or so.
It can even calculate primes faster than my c++ programs XD
Logged
Offline (Female) IsmAvatar
Reply #48 Posted on: May 19, 2010, 11:18:30 pm

LateralGM Developer
LGM Developer
Location: Pennsylvania/USA
Joined: Apr 2008
Posts: 877

View Profile Email
Ah, ok. I'll work around it.
Logged
Offline (Unknown gender) luiscubal
Reply #49 Posted on: May 20, 2010, 06:54:00 am
Member
Joined: Jun 2009
Posts: 452

View Profile Email
Floating point equality comparison is considered harmful by programmers who had to work with it.
Stuff like 0.2+0.2+0.2+0.2+0.2 == 1.0 outputting false in most programming languages(including Java and C++, apparently). Not sure if it's that particular example or something else, but it was something similar.
Logged
Offline (Male) Josh @ Dreamland
Reply #50 Posted on: May 20, 2010, 08:16:05 am

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2950

View Profile Email
luis, flexaplex:
Mark decided he'd take a different approach to the woeful inadequacy of computers' floating point capabilities. While it is true that most languages cannot correctly compare fifths/tenths added together (it is a repeating decimal in binary and therefore can not be represented in a single string of bits of any size), or that sin(pi) == 0 (it's actually 1.2246063538223773e-16), Mark decided that GM should have that capability. That being the case, he made his comparison operators not compare the entire double.

If GM evaluates 1.0000000000001 > 1 as false, Mark is an idiot. ENIGMA will evaluate 1.0000000000001 > 1 and 1.000000000000001 > 1 as true, 1.0000000000000001 > 1 as false. This is because 1.0000000000000001 is simply outside the precision of a floating point value. In actuality, both ENIGMA and GM will store more bits of precision than they check, which is all the solution really needs at this point.


Because of this, I was going to replicate the behavior in ENIGMA by casting to float before comparisons. IEEE tells us that this isn't as simple as just chopping off a large part of the significand, since doubles implement larger exponents as well. But I'm assuming FPUs have a special path just for the occasion.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) luiscubal
Reply #51 Posted on: May 20, 2010, 09:20:18 am
Member
Joined: Jun 2009
Posts: 452

View Profile Email
Floating point handling is dangerous.
I believe GCC tries to "optimize out" those x > y statements(since they are about constants). GCC uses a huge-precision math library during compilation, so 1.0000000000000001 > 1 will probably be just optimized to true, even if we were talking of a precision of only 3 digits in the final executable.
Hopefully, your edge cases were pretty superficial, so there shouldn't be a problem with GCC optimizing it to give the correct result, but be aware that different compilers(even different compiler versions) and different optimizers behave differently.
Even if today your GCC version works, tomorrow an user updates his/her version and everything suddenly stops working.

This is not a problem to be underestimated.
(btw, just curious: does GM use ordinary binary floating point or does it use decimal floating point?)
Logged
Offline (Unknown gender) score_under
Reply #52 Posted on: May 22, 2010, 07:27:36 am

Member
Joined: Aug 2008
Posts: 308

View Profile
(btw, just curious: does GM use ordinary binary floating point or does it use decimal floating point?)
Uses double.
Logged
Pages: « 1 2 3 4
  Print