LB Booster
« Floating point precision »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:49am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Floating point precision  (Read 369 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Floating point precision
« Thread started on: Jan 6th, 2015, 9:22pm »

There's currently a thread at the LB Community Forum discussing the precision of floating-point numbers. Somebody has discovered a strange feature of LB:

Code:
print using( "#.######################", (1/7)*7 )
print using( "#.#######################", (1/7)*7 ) 

LB 4.04 gives:

1.0000000000000000000000
0.99999999999999991611392

In other words attempting to print 23 decimal places rather than 22 produces a less accurate result!

LBB behaves sensibly, the output being:

1.0000000000000000000000
1.00000000000000000000000

I was aware of an anomaly when USING is used to format integers in LB:

Code:
n = 12345678901234567890
print using( "#######################", n ) 

LB 4.04 outputs:

12345678901234567168

whilst LBB outputs:

12345678901234567890

but the misbehaviour with floating-point numbers is a new one on me.

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls