Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 423
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Featured Post

Independent Software Vendors: 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!

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