By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,755 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

Finding the decimal part of a number

P: 3
Please help :)

If I have a number such as 25433.50 or 12.58 how can I get whats after the decimal into its own variable? Also sometimes these numbers will be 1543.3 with only one character after the decimal

Thanks in advance
Aug 15 '07 #1
Share this Question
Share on Google+
4 Replies

Expert 5K+
P: 5,821
Heya, demolish. Welcome to TSDN!

Try this:
Expand|Select|Wrap|Line Numbers
  1. $number = 12.58;
  2. $dpart = $number - (int)$number;
P.S., Changed thread title to better describe the problem (did you know that thread titles that do not follow the Posting Guidelines actually get FEWER responses?).
Aug 15 '07 #2

P: 3
Ugg!!! Why couldn't I think of that! One of those days. I've been thinking about it for about 3 hours. I apologize for the title. Thanks for the info.
Aug 15 '07 #3

P: 3
Just an update, it worked great! Thanks.
Aug 15 '07 #4

Expert 5K+
P: 5,821
Heya, Demolish.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Aug 15 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.