4D v15

Real numbers, Reduction of number of significant digits

Home

 
4D v15
Real numbers, Reduction of number of significant digits

Real numbers, Reduction of number of significant digits  


 

 

Originally introduced in 4D v14 R3

The number of significant digits used for representing the decimals of real numbers has been reduced in 4D:

  • in previous versions, this number was 15 digits
  • in 4D v15 and subsequent versions, it is now 13 digits

This modification concerns only the conversion of real numbers into text, not the way they are represented internally (storage), or arithmetic operations between real numbers. The accuracy of real numbers is not affected.

The new principle implemented consists in no longer including the last two digits, which could not be guaranteed to be significant, in the text representation. The purpose is to limit the number of cases where operations on real numbers produce incorrect results. For example, this will allow us to obtain valid results in the following cases:

OperationResult in 4D < v15Result in 4D v15 and higher
String(3216.36 - 3214.89)"1.47000000000025""1.47"
String(0.321636-0.321489)"0.000146999999999953""0.000147"

Using 13 significant digits for real numbers is usually adequate for computer applications and improves processing of these numbers. Remember that computer calculations on real numbers are always made by approximation since these numbers are expressed internally on a binary basis and not a decimal one. The number of significant digits allows the conversion algorithm to perform the rounding and approximations needed to obtain the expected representation. Similarly, equality comparisons on real numbers are done by analyzing the result when the two numbers are subtracted from each other (in 4D, the degree of accuracy by default of these comparisons can be modified using the SET REAL COMPARISON LEVEL command).

If your 4D application uses the first 15 digits of real numbers, you may need to use other data formats, such as text or long integers. Note that, as explained above, real numbers are not suitable for storage and/or calculation of values with large numbers of significant digits, like serial numbers or astronomical measurements, since their accuracy is limited in nature.

 
PROPERTIES 

Product: 4D
Theme: Language

 
HISTORY 

 
ARTICLE USAGE

4D v15 - Upgrade (standard edition) ( 4D v15)