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
6
Medium Priority
?
421 Views
Last Modified: 2010-04-04
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
Comment
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
  • Learn & ask questions
6 Comments
 

Expert Comment

by:bullen
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

by:
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

by:DragonSlayer
ID: 7077424
a := Int(40011.9786);
b := Frac(40011.9786);
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:DragonSlayer
ID: 7077425
ooops... too late :)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7077520
too late, too :-))
0
 
LVL 46

Expert Comment

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question