bonkyboat
New Member
a$="d:\uk databases\"+Year$+"\supdowns\[5-1]-[4-3]\"+HomeHud$+"-"+AwayHud$+"\"
Posts: 2
|
Post by bonkyboat on Jan 5, 2023 13:07:27 GMT -5
Hello to the community,
Can anyone shed some light on the following,
if you divide 1/13 on a calculator it returns 0.07 (to 2 decimal places) which is correct
however if you do print 1/13 in liberty, it returns 0.76, omitting the correctly placed zero after the dot
Anyone ? Thanks in advance
|
|
|
Post by tsh73 on Jan 5, 2023 14:28:31 GMT -5
print 1/13 x = 1/13 print x print using("#.##",x)
returns
0.76923077e-1 0.76923077e-1 0.08
Are you aware what "e-1" is? It is scientific notation - a shortcut from "*10^(-1)" So 0.76923077e-1 is actually 0.076923077 that is correct.
Probably you misunderstood a bit. (or show your code/results)
|
|
|
Post by Carl Gundel on Jan 9, 2023 18:17:14 GMT -5
Anatoly is right. We need specific code in order to know precisely what problem you are seeing.
-Carl
|
|
|
Post by dan1101 on Jan 10, 2023 4:16:02 GMT -5
An excellent discussion of precision and scientific notation in Liberty BASIC can be found here: www.alycesrestaurant.com/lbpe/Scientific%20precision.htmlAs Anatoly has shown above, by formatting the output with the USING function, the accuracy of Liberty BASIC exactly matches that of the standard Windows 10 calculator. See screenshot below. Try it yourself. print USING("#.#############", 1/13)
|
|
|
Post by Carl Gundel on Jan 10, 2023 8:37:26 GMT -5
Right. Liberty BASIC doesn't actually do any of the floating point math itself. The math coprocessor is used for this.
|
|