Hi,
How do I perform an integer division (e.g. 11 / 3 = 4) in OpenOffice
Basic?
Huh? IME the integer division operator (in languages where it exists)
would produce 11 div 3 = 3, to match the modulus produced by the 'mod'
operator (which does exist in StarBasic).
That said, you can get the behavior you want (rounding) by assigning the
result of a plain division to an integer variable
q% = 11/3 ' Now the value of q% is 4
You can get a more typical integer division by using the available
functions to convert to an integer by rounding down or truncating
roundeddown% = int(11/3) ' value is 3
truncated% = fix(11/3) ' value is 3
These differ when negative numbers are involved. AFAICT truncation is
the one that matches the builtin MOD operator, ie.
b*fix(a/b) + a mod b = a
HTH, Joerg
--
Joerg Barfurth Sun Microsystems - Desktop - Hamburg
>>>>>>>>>>>>>>>>>> using std::disclaimer <<<<<<<<<<<<<<<<<<<<<<<
Software Engineer [EMAIL PROTECTED]
OpenOffice.org Configuration http://util.openoffice.org
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]