discover greebid
Would you like to react to this message? Create an account in a few clicks or log in to continue.

The tips of using Modulo

Go down

The tips of using Modulo Empty The tips of using Modulo

Post  obd2tool Thu Aug 09, 2012 6:16 pm

The modulo operation returns the remainder from the division of two integers. It is available as a function in the obd2 tool of most high-level computer programming languages.A modulo 100 operation on a number will therefore yield these two digits.

1
Choose a cell for the entry of the number from which the last two digits are desired.

2
In an adjacent cell enter the following:
=MOD(A1,100)
Type a positive integer in cell A1 and press ENTER. The last two digits of the number will be displayed in the adjacent cell that you programmed.

4
The base 100 modulo of a negative number returns 100 minus the X-100 Programmer. Using Excel's absolute value function will make the original number positive and fix this problem. Change the entry to:
=MOD(ABS(A1),100)

5
The sign of the dividend was forced positive by the absolute value operation. Restore its sign to the remainder by incorporating Excel's SIGN function:
=MOD(ABS(A1),100)*SIGN(A1)

The modulo operation can be used in X431 Diagun in other high-level programming languages. Depending on the language, the sign of the modulo result may be dictated by either the divisor or the dividend, or it may depend on the specific computer and compiler implementation. The proper handling of negative numbers in modulo operations in other languages may therefore vary.
In the C and C++ languages: if the dividend or divisor is negative, the sign of the result is not defined. The analogous statement to our Excel example is:
remainder = (abs(dividend))%100

With the C languages it is not clear what the sign of this result will be.
In Visual Basic, it is the sign of the divisor and not the dividend that determines the sign of the result. The divisor is always a positive 100 so the result will always be positive. Multiplying it by the sign of the AUTOCOM PRO will produce the proper sign in the result:
remainder =Mod (100)*sgn(dividend)

obd2tool

Posts : 13
Join date : 2012-07-31

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum