Skip to main content
1-Visitor
May 28, 2025
Solved

Error in logical statements (Floating points error?)

  • May 28, 2025
  • 1 reply
  • 467 views

There seems to be an error regarding logical statements in Prime 10.0.1. See below.
The expected output of all statements is 1. It seems to only be a problem when using units.

BA_13569641_0-1748415581253.png

 Is there a fix to this? Thanks

Best answer by Werner_E

What you experience is a combination of inaccuracies in unit conversion (even though its only a multiplication by 10^-3 as Prime is always going back to the base units) and the 'natural' accuracy limit of the IEEEE number format used.

A 'fix" is to use a system which is using a number format which can provide more accuracy then the typical 14-16 decimals of the IEEE storage format.

Primes built-in symbolic engine provides more accuracy and could be used. Using the symbolic evaluation (->) instead of the numeric (=) one gives the correct result for your example. You may want to check "Unit/Constants in Symbolics" in the Calculation Options.

Werner_E_0-1748437116614.png

 

Sometimes it may be necessary to add the "simplify" modifier to get a meaningful result:

Werner_E_1-1748437273738.png

 

 

1 reply

Werner_E25-Diamond IAnswer
25-Diamond I
May 28, 2025

What you experience is a combination of inaccuracies in unit conversion (even though its only a multiplication by 10^-3 as Prime is always going back to the base units) and the 'natural' accuracy limit of the IEEEE number format used.

A 'fix" is to use a system which is using a number format which can provide more accuracy then the typical 14-16 decimals of the IEEE storage format.

Primes built-in symbolic engine provides more accuracy and could be used. Using the symbolic evaluation (->) instead of the numeric (=) one gives the correct result for your example. You may want to check "Unit/Constants in Symbolics" in the Calculation Options.

Werner_E_0-1748437116614.png

 

Sometimes it may be necessary to add the "simplify" modifier to get a meaningful result:

Werner_E_1-1748437273738.png