www.beck-ipc.com

@CHIP-RTOS C Library - TCP/IP API


Crypt_BN_Div

Big number division.

int far Crypt_BN_Div (
             const Crypt_BigNumConstS far *dividend,
             const Crypt_BigNumConstS far *divisor,
                   Crypt_BigNumS      far *quotient,
                   Crypt_BigNumS      far *remainder ) ;

Parameters

dividend

[in]   Pointer to big number to be divided (numerator).

divisor

[in]   Pointer to big number to be used as demoninator.

quotient

[out]   Resulting quotient will be written here.   This output parameter is optional and may be set to NULL if the resulting quotient value is not needed.

remainder

[out]   The remainder resulting from the divide operation will be written here.   This output parameter is optional and may be set to NULL if the remainder is not needed.

Return Value

error code:
    0 - Success (no error).
    1 - Memory allocation failed.
    3 - Invalid big number size.
    5 - No solution found (e.g. divisor was zero).

Comments

The value computed is:

     quotient = dividend / divisor ;

The divisor must not exceed 512 bytes size or an error will result.   The dividend may range up to twice this size, plus one extra digit, for a total of 1028 bytes.

This API has two output parameters, quotient and remainder.   Both of these output parameters are optional and either pointer parameter can be set to NULL if the respective result is not needed.   Otherwise these must reference a Crypt_BigNumS object.

Either of the two output parameters may reference one of the two input values, if the caller no longer needs the old values.   This will not affect the resulting calculation.   Note that Crypt_BigNumS and Crypt_BigNumConstS structure definitions are identical other than the bnDataPtr member's const nature, so pointers to these two types can can safely be cast to one another.

For the Crypt_BigNumS object referenced by the output parameters quotient and remainder, only the bnDataPtr member must be initialized by the user.   The reference buffer must have space for divisor->bnDigitCnt digits, where each digit is an unsigned int type.

This function requires an 8 kByte workspace allocated from the system memory.   The function will execute significantly faster if this workspace memory is available in the system's fast memory area.

See Also

RTOS API

On the first call, this library function invokes a software interrupt which modifies the code at the calling site inside your application program.   A direct FAR JMP into the @CHIP-RTOS-x86 implementation for this function is installed so that on return and on any subsequent calls to this API this dynamic link reaches the function's implementation directly.

Supported since or modified in @CHIP-RTOS version

    SC12SC13SC11SC1x3SC2x
    n/an/an/aV1.35V1.35

Supported by @CHIP-RTOS C Library since version

    CLIB
    V2.19

This API List
List of C Libraries
@CHIP-RTOS Main Index


End of document