Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Extract the decimals from a float.

Posted on 2002-06-13
Medium Priority
421 Views
How can I extract the decimals and the other part of a float?

for example if I have

40011.9786

and want them in 2 variables.

a = 40011
b = 9786

how can I do that?
0
Question by:wqclatre
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

Expert Comment

ID: 7077419
Try

Int() and Frac()

Frac gives You 0.9786 If You want to it to be an Integer value You must know how many decimals You vant. Example

I = Int(Frac(X)*10000) // gives an integer betveen 0 and 9999.

bullen
0

LVL 46

Accepted Solution

aikimark earned 200 total points
ID: 7077423
1. assign value to an integer variable
2. assign expression (value - (1)VARIABLEvalue) to a real variable, where (1)VARIABLEvalue is the integer variable used in step 1.
0

LVL 14

Expert Comment

ID: 7077424
a := Int(40011.9786);
b := Frac(40011.9786);
0

LVL 14

Expert Comment

ID: 7077425
ooops... too late :)
0

LVL 27

Expert Comment

ID: 7077520
too late, too :-))
0

LVL 46

Expert Comment

ID: 7078124
This question was "pounced upon" wasn't it.  So many answers, just waiting for a question.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
###### Suggested Courses
Course of the Month8 days, 2 hours left to enroll