LO Calc Basic (Macro): How to work with integers

Question

I am trying to write a very simple function equivalent to this C/C++/Java/…, but in LO Calc Basic

int test( int v) { return v / 10; }

// test(3) -> 0
// test(6) -> 0
// test(14) -> 1
// test (18) -> 1
// test(22) -> 2

The problem is, Calc seem to Ceil or Round integer operations instead of the expected flooring.

function test( v as Long) as Long
    test = v/10
end function 

// test(3) -> 1
// test(6) -> 1
...

I also tried to create a floor function (Math.Floor is missing for any reason in LO) but does not help:

function floor( v as Double ) as long
    floor = v-(v Mod 1)
end function

function test( v as Long) as Long
    test = floor(v/10)
end function

This unfortunately and without rational, return also the ceil value.

EDITED: Ok, it seem my “floor” function is hidden by the Calc FLOOR function. So I still don’t know how to write a working Floor function. Why Calc don’t have just the normal Math.floor()?

Thanks for any help.

Ok, after some more research, I found a trick to have a “floor” function and making this code:

function Int( v as Double ) as Long
dim aux as Long
aux = v
if aux > v then 
	Int = aux-1
else 
	Int = aux
endif
end function


function test ( v as Double ) as Long
    test = Int( v / 10)
end function