Divide or division: Great Cow BASIC support division. Division can set the global system variable SysCalcTempX to the remainder of the division. However the following simple rules apply. . If both of the parameters of the division are constants, the compiler will do the calculation itself and use the result rather than making the microcontroller work out the same thing every time. So, if there are two constants used, the microcontroller division routine does not get used, and SysCalcTempX does not get set. . If either of the parameters of the division are variables, the compiler will ensure the microcontroller do es the calculation as the result could be different every time. So, in the this case the microcontroller division routine does get used, and SysCalcTempX is set.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In GCB when you divide variables, are the results rounded, truncated or something else?
For example:
aa = 25
bb = 7
aa / bb = 3.57 Does GCB round to 4 or truncate to 3 or does it do something else?
Rather then tell you it is better to show you so here is a test program:
The resut from the Terminal is:
~~~
25 / 7 = 3 Remainder 4
~~~
Cheers
Chris
@MBB it's integer, word or long word. No decimal point float in gcb.
25/7=3
@MBB it's integer, word or long word. No decimal point float in gcb.
25/7=3
Thanks!
And....from the Help: Setting Variables
Divide or division: Great Cow BASIC support division. Division can set the global system variable SysCalcTempX to the remainder of the division. However the following simple rules apply. . If both of the parameters of the division are constants, the compiler will do the calculation itself and use the result rather than making the microcontroller work out the same thing every time. So, if there are two constants used, the microcontroller division routine does not get used, and SysCalcTempX does not get set. . If either of the parameters of the division are variables, the compiler will ensure the microcontroller do es the calculation as the result could be different every time. So, in the this case the microcontroller division routine does get used, and SysCalcTempX is set.