Difference between revisions of "Set"

7 bytes added ,  12:44, 17 April 2006
m
no edit summary
imported>JOG
m
imported>JOG
m
Line 27: Line 27:
In integer divisions the remainder is truncated at the end of the operation:
In integer divisions the remainder is truncated at the end of the operation:


''set a to 9/5'' will set a to 1
set a to 9/5     ; will set "a" to 1
 
set a to 10*9/5 ; will set "a" to 18
''set a to 10*9/5'' will set a to 18




To accomplish correct rounding in integer divisions you need to add 0.5:
To accomplish correct rounding in integer divisions you need to add 0.5:


''set a to 9/5+0.5'' will set a to 2
set a to 9/5+0.5 ; will set "a" to 2
 
set a to 7/5+0.5 ; will set "a" to 1
''set a to 7/5+0.5'' will set a to 1




Anonymous user