Solved

decimal part of number.

Posted on 1998-09-01
2
271 Views
Last Modified: 2008-03-17
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
Comment
Question by:steph84
2 Comments
 
LVL 4

Accepted Solution

by:
binkzz earned 50 total points
ID: 1204628
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
 
LVL 84

Expert Comment

by:ozo
ID: 1204629
also POSIX::modf
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl count the hash for print 4 165
PERL export multiple query results to a JSON file 1 165
Perl output collect 7 67
Excel to CSV conversion with specific columns 5 82
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question