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

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.
0
steph84
Asked:
steph84
1 Solution
 
binkzzCommented:
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

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

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