• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 425
  • Last Modified:

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?
0
wqclatre
Asked:
wqclatre
1 Solution
 
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
 
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
 
DragonSlayerCommented:
a := Int(40011.9786);
b := Frac(40011.9786);
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
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.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now