decimal part of number.

Easy quesion : I want to know if there is an operator to test if a number is int or a function to get the decimal par t of a number, like int for the integer part.
steph84Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
binkzzConnect With a Mentor Commented:
Say $numbertochop = 2314.123
then

$numberint = int $numbertochop           # $numberint is now 2314
$decimal   = $numbertochop - $numberint; # $decimal is now .123

Or in one line:

$decimals = $number - (int $number);

Hope this helps,
Binkzz
0
 
ozoCommented:
also POSIX::modf
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.