Jump to content
  • entries
    469
  • comments
    324
  • views
    406,677

GwBasic/Basica gives strange answer


Serguei2

1,779 views

Hi

 

My calculator has stopped working and I need answer now.

 

I used Basica to get the result of 682.80 - 587.34

 

Here I get from Basica

 

blogentry-1196-0-47789100-1352141839_thumb.png

 

682.80 - 587.34 = 95.45996

 

I checked to Vic 20 on emulator. Here I get:

 

blogentry-1196-0-51244100-1352141940_thumb.png

 

682.80 - 587.34 = 95.46

 

And I wrote this problem on paper to be sure:

 

blogentry-1196-0-18524500-1352142514_thumb.jpg

 

 

95.45996 on IBM PC. :lol: :rolling: :rolling: :rolling: :rolling: :rolling: :rolling: :rolling: :rolling: :rolling: :rolling: :rolling: :rolling:

 

 

Robin Gravel

 

 

PS - Here a screenshot from Pet

blogentry-1196-0-77878500-1352152207.png

 

Either the emulator's too good or IBM PC's very bad.

3 Comments


Recommended Comments

In most cases the BASIC interpreter of that generation didn't have floating point hardware and was written to be memory efficient. So BASIC may not have actually implemented true floating point, and certainly not to the IEEE specifications.

 

But let's look at the question in terms of what a typical floating point (using 32 bit mantissas) would do:

 

682.80 - 587.34

682.80 = $1.55666666 * 2^9

587.34 = $1.25AB851F * 2^9

difference = $0.2FBAE147 * 2^9 = 95.45999991893768310546875

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...