longdiv()

longdiv()

Description

This function is used to divide 64-bit numbers.

Mathematical function which divides val with val2 (val/val2=res).

Syntax

longdiv(valL, valH, val2L, val2H, resL, resH);

Parameters

Variable

Input

Variable

Input

valL

variable which holds least significant 32 bits of number you want to divide with val2.

valH

variable which holds most significant 32 bits of number you want to divide with val2.

val2L

variable which holds least significant 32 bits of number you want to divide with val.

val2H

variable which holds most significant 32 bits of number you want to divide with val.

rezL

variable which will hold most significant 32 bits of division result between val and val2.

rezH

variable which will hold least significant 32 bits of division result between val and val2.

Returns

Always returns SCRIPT_OPERATION_SUCCESS.

Function call example

Example of 64 bit division
new Number1MSB = 100; new Number1LSB = 20; new Number2MSB = 0; new Number2LSB = 5; new ResultMSB = 0; new ResultLSB = 0; main() { longdiv(Number1LSB, Number1MSB, Number2LSB, Number2MSB, ResultLSB, ResultMSB); // ResultMSB = 20 and ResultLSB = 4 for(;;) { Delay(1000); } }