Integer Value from a Decimal Number ???

Status
Not open for further replies.

BCox5351

New Member
Does anyone have a way to extract the integer value from a decimal number? OshonSoft does not seem to have an Integer(x) function.
 
I do not use OshonSoft so if I get this wrong please correct me.

Depends on what you want to do with the fractional part. Do you want to round or truncate ?

You should be able to truncate by saying

IntVar = decimalVar

to round just add .5 to the decimalVar first
 
Last edited:
Does anyone have a way to extract the integer value from a decimal number? OshonSoft does not seem to have an Integer(x) function.

Hi
Can you post an example of the numbers you are working with.??

I may be able to suggest a simple work around.
 
I found a trick or not

Dim arg1 as Single
Dim arg2 as Single 'decimal part from arg1
Dim arg3 as Long 'integer part from arg1

arg3 = arg1 Mod 0
arg2 = arg1 - arg3
 
Mod can not be used on a single... However arg3 = arg1 is in fact the same as casting as arg3 will lose the floating point part
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…