Solved

How to get the decimal part alone from a float number.

Posted on 2006-06-19
5
1,206 Views
Last Modified: 2013-12-13
How to get the decimal part alone from a float number.
for eg : $x= 15.25
what to get .25 from $x

Thanks in advance.
LWord
0
Comment
Question by:lword
  • 3
  • 2
5 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 16933063
$x= 15.25;
$f = $x - (int)$x;
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16933179
$f = fmod($x, 1);
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16933181
Oh!

Hadn't been answered as I typed in my response.

Oh!
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16933184
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16933616
Interesting answer, RQuadling. will try to remember that...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

766 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