integer divide

Hello everybody and Happy New Year! I am having some issues with integer divides.
The following code will show the issue. Set either cUSE_BAP28 or cUSE_BAP40 to 1 depending on what chip you are using.
The output will be 7468676/360000=21? According to the manual the result should be 20 because it shouldn’t round (7468676/360000=20.74632).
I have this problem with IDE 8.0.1.8 and the new Studio 1.0.0.15 using the BAP28 or the BAP40 using byte, word or long variables.

What am I doing wrong? Thanks for any ideas!

From the manual:
/ (division)
Integer division discards fractional results. For example:
result = 76/7
will set the variable “result” to a value of 10. (The actual decimal result
should be 10.857… but the decimal part is discarded, rounding is not
done.)

cUSE_BAP40 con 1
cUSE_BAP28 con 0

main
nIntegerDivide var long

nIntegerDivide = (7468676/360000)
#if (cUSE_BAP40)
	enablehserial
	sethserial H38400, H8DATABITS, HNOPARITY, H1STOPBITS
	hserout "7468676/360000=", dec nIntegerDivide, "?", 13]
#endif
#if (cUSE_BAP28)
	serout S_OUT, I38400, "7468676/360000=", dec nIntegerDivide, "?", 13]
#endif
end

-Bob

Don’t know, this sounds like something for Nathan…
Kurt

Looks like they may be making more changes.

Alan KM6VV

I’ll have to check this out. It should truncate, not round.