Extract the decimals from a float.

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?
LVL 2
wqclatreAsked:
Who is Participating?
 
aikimarkCommented:
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
 
bullenCommented:
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
 
DragonSlayerCommented:
a := Int(40011.9786);
b := Frac(40011.9786);
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
DragonSlayerCommented:
ooops... too late :)
0
 
kretzschmarCommented:
too late, too :-))
0
 
aikimarkCommented:
This question was "pounced upon" wasn't it.  So many answers, just waiting for a question.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.