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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
aikimarkConnect With a Mentor Commented:
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
All Courses

From novice to tech pro — start learning today.