classicgamer_27330 Posted November 23, 2016 Share Posted November 23, 2016 Say I type a program like 10 Let a=b/c 20 print c what do I need to put in between so that C will be in the thousandths place (like 2/4 is .500) or 5/9 would be .555 Quote Link to comment Share on other sites More sharing options...
JamesD Posted November 23, 2016 Share Posted November 23, 2016 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. Quote Link to comment Share on other sites More sharing options...
Iamgroot Posted November 23, 2016 Share Posted November 23, 2016 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$ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.