Sorry guys, I keep having to search to get the results. For some reason DIV and MOD usage are not explained anywhere on the online help. So I just want to put this here so I can book mark to it. And yes, I do use mibuso for some of my code repository.
x := 5 DIV 2
y := 5 MOD 2
RESULT:
x = 2
y = 1
0
Comments
MOD is Modulus (I think, not quite sure about the word) but gives you the remainder of integer division.
So ((5 DIV 2) * 2) + (5 MOD 2) = 5.
I always have to put it on a test form to figure out which one is which :oops:
RIS Plus, LLC
No, there is no problem, just lack of documentation. But these functions is common in other languages and it is not problem to find the meaning...
http://en.wikipedia.org/wiki/Modulo_operation
I think that DIV do not need more explanation... ;-)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
is this known :?:
Great book, an it has all this stuff in it.
And knowing is half the battle.
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
RIS Plus, LLC
The Integer Divide (DIV) OperatorThe integer divide operator is used only as a binary operator. Its purpose is to
divide the numeric term preceding it by the numeric term following it. The result
type of this division is always of type Integer. If the second term is zero (0), a
run-time error occurs. Any decimals that resulted from an ordinary division are
dropped. Therefore, the result of 17 DIV 8 is 2, whereas the result of 17 DIV 9 is
1.
The Modulus (MOD) OperatorThe modulus operator (or the remainder operator) is used only as a binary
operator. Its purpose is to divide the numeric term preceding it by the numeric
term following it by using the integer division method and then return the
remainder of that division. The result of this operation is always of type Integer.
If the second term is zero (0), a run-time error occurs. The following shows
examples of modulus operator usage.
• 17 MOD 8 = 1
• 17 MOD 9 = 8
The modulus operator requires two numbers. The first number is the one that is
converted by using the modulus function and the second number represents the
number system being used. By definition the number system starts at zero and
ends at the second number minus one. For example, if the second number is ten,
the number system that is used is from zero to nine. Therefore, the modulus
represents what the first number converts to, if the numbering system only had
the number of values indicated by the second number and the first number is
forced to restart from zero.
The following example shows several modulus operations:
• 15 modulus 10 is 5 (because 9 is the last number available, 10 is
represented by going back from the start, or zero, 11 is 1, 12 is 2, and
so on)
• 6 modulus 10 is 6
• 10 modulus 10 is 0
• 127 modulus 10 is 7
The result is the same if the first number is divided by the second by using an
integer only and the remainder is returned as the value.
shona
That which you seek inside is that which you find outside
We used to manually cut the Qty to Invoice in half , which therefor cuts the invoice amount in half.
Then we post with 30 days terms. Then we post the (remaining) other half with 60 days terms.
Giving us two vendor ledger entries with the correct terms. But then we started getting these terms on PO's that had 100 items and manually this was exhausting. So using MOD I can see if the amount is cleanly divisible by 2 & if not it gives us a message to check the Item and handle that manually.
Hail MOD!!
Remainder := Purchline."Quantity Received" MOD 2;
IF Remainder <> 0 THEN MESSAGE('Item %1 Needs Rounding',Purchline."No.");
http://www.BiloBeauty.com
http://www.autismspeaks.org
Has anyone tried to use DIV in combination with BigInteger in NAV2009 RTC?
If you execute following code in NAV2009 you'll get following messages:
Message in Classic Client (which is correct):
Microsoft Dynamics NAV Classic
88
OK
Message in Role Tailored Client (which is incorrect):
Microsoft Dynamics NAV
235002258041864280
OK
Anyone got any ideas?
The reminder is dividend minus quotient times dividend.
so, if
A DIV B = Q Then
A MOD B = A - B * Q
-2 DIV 4 = 0
-2 MOD 4 = -2 - 0 * 4 = -2
-3 DIV 4 = 0
-3 MOD 4 = -3 - 0 * 4 = -3
-5 DIV 4 = -1
-5 MOD 4 = -5 - (-1) * 4 = -5 + 4 = -1