Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - PROFESPAN@frontier.com

Pages: [1]
1
Below please see a QB64 program that evokes mathematical errors in some DOUBLE PRECISION numbers. In particular, PRINT 1.D-40 produces 1.D-41, which is ten times smaller than the correct answer 1.D-40.

Here is the test program:

Data 1D-40#,1E-40
Read x#, y!
Print .0000000000000000000000000000000000000001#: Rem:      1D-41 is the result
Print 1# / 10000000000000000000000000000000000000000#: Rem: 1D-41 is the result
Print x#
Print 10000000000000000000000000000000000000000#: Rem:      1D+40 is the result
Print 1# / 10000#: Rem:                                     .0001 is the result
Print .0001#: Rem:                                          .0001 is the result
Print 1D0 / 1.D40: Rem:                                     1D-41 is the result
Print 1D-40: Rem:                                           1D-41 is the result
Print 1D0 / 1D20: Rem:                                      1D-21 is the result
Print 1D-20: Rem:                                           1D-21 is the result
Print 1D0 / 1D19: Rem:                                      1D-19 is the result
Print 1D-19: Rem:                                           1D-19 is the result
Print 0.0000000000000000000000000000000000000001:  Rem:     1D-41 is the result
Print 1 / 10000000000000000000000000000000000000000.: Rem:  1D-41 is the result
Print y!: Rem:                                       9.999946E-41 is the result
Print 10000000000000000000000000000000000000000.: Rem:      1D+40 is the result
Print 1 / 10000:                                       Rem: .0001 is the result
Print .0001: Rem:                                           .0001 is the result
Print 1E0 / 1E40: Rem:                               9.999946E-41 is the result
Print 1E-40: Rem:                                    9.999946E-41 is the result
Print 1E0 / 1E20: Rem:                                      .0001 is the result
Print 1E-20: Rem:                                           .0001 is the result
Print 1E0 / 1E19: Rem:                                      1D-19 is the result
Print 1E-19: Rem:                                           1D-19 is the result
End

Note that 1D-19 prints correctly but 1D-20 does not. SINGLE precision seems to work ok.

It may make a difference if the decimal point is included in some of the numbers, for instance, 1.D-40 instead of 1.D-40. However, the errors may be worse.

Please fix this problem.
Sincerely yours,
Dr. Edwin L. Kerr, Retired NASA physicist and engineer with 60 years of computer programming experience.

Pages: [1]