LUALoriotPro WEB site

LoriotPro scripting documentation
Extensions for LUA language

Table of contents Search function

Print the current page Mail this  link UTUBE Channel version française

lp.ui64div - Division between two unsigned 64 bits

LoriotPro has extended the LUA sripting language by providing its own LUA libraries. The new functions provided are dedicated to the creation of monitoring and SNMP automation application.

Syntax

value, ‘buffer’ = lp.ui64div(value1 , value2);

Description

The lp.ui64div LUA function provides the integer result of a division between two unsigned 64 bits values coded and defined as double.

With huge number in Standard LUA , the usage of double generate calculation error on unsigned 64 bits number. As unsigned 64 bits numbers are more currently used in SNMP V2 it is mandatory to use these 64 bits functions available in the LoriotPro environment for the manipulation of 64 bits counter for example.

Parameters

value1 - An usigned 64 bits number defined in a double

value2 - An usigned 64 bits number defined in a double

Return Values

value : The result of the operation as an integer

buffer : The result of the operation as a character string representing an unsigned 64 bits value.  

Warning a division by 0 return the value ‘#DIV0'

Return nil if an error occurs

Example

We do perform multiple divisions to show the relevance of this function.

The LUA code :

value,buffer=lp.ui64div(100,10);

lp.Print("Value : ",value," buffer : ",buffer,"\n"); 

value,buffer=lp.ui64div(10,100);

lp.Print("Value : ",value," buffer : ",buffer,"\n"); 

value,buffer=lp.ui64div(0xFFFFFFFFFFF,567);

lp.Print("Value : ",value," buffer : ",buffer,"\n"); 

value,buffer=lp.ui64div(30.10,3);

lp.Print("Value : ",value," buffer : ",buffer,"\n");

 

Les résultats : 

64 bit division with LUA

 

 


www.loriotpro.com