Jump to content
IGNORED

Rounding in Applesoftbasic


classicgamer_27330

Recommended Posts

I'm not sure there's an easy answer to that due to the way floating point is represented, and the fact that Applesoft has no functions to get a specific number of floating point digits.
The closest thing I've found on any BASIC, would be to use PRINT USING to convert to a formatted string with 3 decimal places, and then convert it back to a floating point number.
Applesoft doesn't have PRINT USING.

Link to comment
Share on other sites

If you don't care about the zeroes after the first and/or second decimal digits, you can do this:

 

15 a=int ((b/c) * 1000) / 1000

 

If you need the zeroes at the end of the decimal number, then you would have to convert to a string

 

10 b=2:c=4

15 a=int((b/c)*1000)

17 a$="0"+str$(a):L=Len(a$):b$=left$(a$,L-3):c$=right$(a$,3)

20 ?b$"."c$

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   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...