ROS math routines

Here you can discuss ReactOS related topics.

Moderator: Moderator Team

Post Reply
Posts: 1
Joined: Sat Oct 03, 2015 1:55 am

ROS math routines

Post by yosimtysam »

Windows (apparently all of them) have a problem with certain [floating point] math routines. Will this be resolved in ROS or must it stay in place to be truly Windows compatible?

The problem has exists in Windows such that when this formula is computed "Square Root of 4 minus 2" by any Windows application - Calc, Excel, etc, the result is expected to be zero. Square root of 4 is 2, subtract 2, equals zero. However, windows computes this answer as -8.1648465955514287168521180122928e-39, which is incredibly small, but not zero. I'm not sure if this is even software; is the FPU in the CPU somehow to blame? The problem may be in the way roots are processed. Windows displays the "square root of 4" as 2, but it's held in its registers as something like 1.9999999999999999999999999999999999999999999999999999999, so when subtracting the integer 2 it becomes that -8.... stuff.
Posts: 860
Joined: Sat Dec 20, 2008 5:55 pm
Location: Izmir, TR

Re: ROS math routines

Post by erkinalp »

This is not something we can really solve. Only programs themselves can organise formulas in a stable way.
-uses Ubuntu+GNOME 3 GNU/Linux
-likes Free (as in freedom) and Open Source Detergents
-favors open source of Windows 10 under GPL2
Posts: 1036
Joined: Tue May 07, 2013 9:18 pm
Location: California, USA

Re: ROS math routines

Post by middings »

You are correct, yosimtysam. The discrepancy is due to the way roots are processed in digital computers. Digital computers can only represent a finite number of values and those values must themselves have a finite representation. This limits the possible values that a digital computer can represent. Values a digital computer cannot represent exactly are adjusted to a value the digital computer can represent. This can cause the digital computer's results to be inaccurate. Designers of digital computers choose methods of representing numbers based on the practical needs of users for precision and accuracy, speed of computation, and cost.
User avatar
Posts: 4473
Joined: Sun Nov 28, 2004 7:52 pm
Location: Germany, Bavaria, Steinfeld

Re: ROS math routines

Post by EmuandCo »

I would say this is a coding error and nothing more. The precision of the FPU is well known and to output a result with waaaay more decimal places than the precision would be able to calculate + not rounding if maybe needed is a problem of the coder IMO.
ReactOS is still in alpha stage, meaning it is not feature-complete and is recommended only for evaluation and testing purposes
Posts: 1787
Joined: Fri Aug 07, 2009 5:11 am
Location: USA

Re: ROS math routines

Post by PurpleGurl »

My goodness! I'm using a Dell Dimension 4700 right now because I think the motherboard (Intel X79 chipset) is bad in my nicer PC. This machine has XP on it. It tried it both in regular mode and scientific mode. In scientific mode, there is no square root key, but you can use "inverse square" for square root, and sure enough, in either mode, that long -8 ^ -39th number was the result. Even using parenthesis in scientific mode to box in the inverse square from the subtraction, the result is still that long odd negative number. I have no idea if that will be different in ROS.

As a side comment, I used to hack around with calculators. For instance, on many solar calculators with no off button, if you hold down 2 certain numbers at the same time, it functions as an off switch.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 1 guest