Hi,
If I have a number, say 100, and divide that by 16, the answer would be 6.25
How do I take that answer and determine that there is a whole number AND a remainder?
Many thanks,
Brian
Hi Brian,
The CB code below does what you are after, but I was not able to get the same code to work with IWB. The decimals only show "00".
Not yet been able to figure out why.
Egil
openconsole
def a:int
def b:float
a=100/16
b=(100/16)-a
print"int(100/16)=",a
print"Remainder: ", b
do:until inkey$<>""
closeconsole
end
Brian,
Modified the CB code above to read:
openconsole
def a:int
def b:float
a=100/16
b=100.00/16.00
print"100/16 = ",a
print"Remainder: ", b-a
do:until inkey$<>""
closeconsole
end
Now the code works both with CB and IWB.
Good luck,
Egil
Or was this what you had in mind..
openconsole
double a=100.0/16.0
double b=(a-int(a))*16.0
print "100/16=",int(a)
print "Remainder=:",int(b)
do:until inkey$<>""
closeconsole
Later,
Clint
Thanks, Chaps,
I'll have a look at all the answers later. Just at the wife's beck and call at the moment!
Brian
Way to much work, see: % - Modulus-The remainder of an integer division. Under Operators and Mathematical Expressions. Does exactly what you are looking to do and is built into the language.
answer = 155 % 100. returns 55.
Bill
Brian,
You probably want what both Clint and Bill are suggestion. I was thinking decimals only, not the remainder of an integer division.
But anyway, now you have suggestions for both ways.
Bill,
Looks like I had a senior moment and I'm not even a senior. Your right, and I knew that. :-[
Later,
Clint