LB Booster
Programming >> Language extensions >> High-precision scientific notation http://lbb.conforums.com/index.cgi?board=extensions&action=display&num=1516728078 High-precision scientific notation
Post by Richard Russell on Jan 23rd, 2018, 4:21pm
LB 4 (including 4.5.1) performs floating-point arithmetic internally with a precision of approximately 15 to 16 significant figures, which should be good enough for most applications. But, strangely, if the calculation returns a value that must be represented in scientific (exponential) notation - because it is too large or too small for fixed-point format - LB will print the result only to a precision of 8 significant figures!
For example suppose you want to calculate 123456789^-20; LB knows what the answer is to an accuracy of at least 15 digits but the best you can print (easily) is:
Code:
0.14780886e-161
This limitation arises because, uniquely in my experience, the LB 4 implementation of the USING() function does not give you the opportunity of specifying that scientific notation should be used. This omission is fixed in LBB:
Code:
print using ("###.###################^^^^", 123456789^-20)
which gives:
Code:
1.4780885631555544717E-162
(all the digits are significant).
Here's a program for printing all the powers from +42 to -42 (only a fraction of the range that LBB is capable of):
Code:
a = 123456789
for n = 42 to -42 step -1
b = a^n
print n;tab (10); using ("###.###################^^^^",b)
next n
end