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

Math Help Needed

P: n/a
I'm doing some php math and need to divide a floating point number
variable by only 4 decimal places - when I do the following:

$aspect_ratio = 942 / 760;
$new_height = $target_width * $aspect_ratio;

In PHP $aspect_ratio claculates to 1.2394736842105 but for my purposes
I need only 1.2394

How can I limit the decimals to just 4 places?

Thanks...

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

On 14-Nov-2003, Ralph Freshour <ra***@primemail.com> wrote:
I'm doing some php math and need to divide a floating point number
variable by only 4 decimal places - when I do the following:

$aspect_ratio = 942 / 760;
$new_height = $target_width * $aspect_ratio;

In PHP $aspect_ratio claculates to 1.2394736842105 but for my purposes
I need only 1.2394

How can I limit the decimals to just 4 places?


lookup round() or number_format()

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #2

P: n/a
round($aspect_rating, 4)

:)

"Ralph Freshour" <ra***@primemail.com> wrote in message
news:uv********************************@4ax.com...
I'm doing some php math and need to divide a floating point number
variable by only 4 decimal places - when I do the following:

$aspect_ratio = 942 / 760;
$new_height = $target_width * $aspect_ratio;

In PHP $aspect_ratio claculates to 1.2394736842105 but for my purposes
I need only 1.2394

How can I limit the decimals to just 4 places?

Thanks...

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.