Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top