Ultimate Amiga
Network Boards => AMOS Language Discussion => AMOS Factory => AMOS Professional Forum => Topic started by: xboxisfinished on 21 May, 2015, 09:04 PM
I have set a timer with # float on it. When the timer goes down in decimal point -0.01 it goes down fine
2.00, 1.99, 1.98, 1.97, etc...respectively! Sweet! Problem I have when it reaches 0.98, decimal then it adds 0.980000000 on it
how do I fix it so it contain the format
#0.00 only?
Thanks in advance.
Fixed point is easier to work with than floating point. Just make an integer variable that is 100 times greater and then print n/100;".";n mod 100
If you must use floating point, you'll have to use string manipulation to avoid the rounding error.
Quote from: SamuraiCrow on 23 May, 2015, 04:03 PM
Fixed point is easier to work with than floating point. Just make an integer variable that is 100 times greater and then print n/100;".";n mod 100
If you must use floating point, you'll have to use string manipulation to avoid the rounding error.
Assuming I want to use the string manipulation. Can you give me an example of how to do that? Like a format string manipulation?
Thanks in advance.
If you are using the Print instruction to do this output you can add a Using directive to it and specify the exact format of the output:
Print Using "#.##";TIMER#
This should limit the output to 1 digit before the decimal point and two digits after.
Quote from: Sidewinder on 24 May, 2015, 06:03 PM
If you are using the Print instruction to do this output you can add a Using directive to it and specify the exact format of the output:
Print Using "#.##";TIMER#
This should limit the output to 1 digit before the decimal point and two digits after.
Thank you so much! :)
Huh. I looked into the online manual for print using and could not find it.
Quote from: SamuraiCrow on 26 May, 2015, 07:04 PM
Huh. I looked into the online manual for print using and could not find it.
It is there! It works!! Weeeee!!!
Yeah, it took me some time to find it too. It's under "Using" in the index, section 5.6.13.