getting the decimal part of a number

Discussions about editing and cleaning data
Post Reply
AriSilva
Posts: 470
Joined: July 22nd, 2016, 3:55 pm

getting the decimal part of a number

Post by AriSilva » November 25th, 2020, 6:43 am

Is there an easy way to get that?
For example:
i = 23.45678;
j = fn(i);
j would be .45678

I´m using now a maketext to string, then string to number and then a subtraction, like:
i = 23.456789;
x = maketext("%7.0f", i);
j = tonumber(x);
k = i - j;
Best
Ari

Gregory Martin
Posts: 1418
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: getting the decimal part of a number

Post by Gregory Martin » November 25th, 2020, 8:54 am

How about using the int function:
numeric decimal_part = value - int(value);

AriSilva
Posts: 470
Joined: July 22nd, 2016, 3:55 pm

Re: getting the decimal part of a number

Post by AriSilva » November 26th, 2020, 4:38 pm

Gee,
I swear I´ve went down all over the alphabetical list of functions and did not see it.
Thanks Greg
Best
Ari

Post Reply