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

Variable value gets rounded off

P: n/a
hi all, while im computing large values the variable value gets
rounded off to the next higher value .How do we stop or prevent this
happening.
Jan 3 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
..oO(Lawrence)
>hi all, while im computing large values the variable value gets
rounded off to the next higher value .How do we stop or prevent this
happening.
How large is "large"? What about a code example?

Micha
Jan 3 '08 #2

P: n/a
On Jan 3, 10:34 am, Michael Fesser <neti...@gmx.dewrote:
.oO(Lawrence)
hi all, while im computing large values the variable value gets
rounded off to the next higher value .How do we stop or prevent this
happening.

How large is "large"? What about a code example?

Micha
$a=$b+$c+$d
where $b=99999999999999
$c=99999999999999
$d=99999999999999

Jan 3 '08 #3

P: n/a
Lawrence <la*****@gmail.comwrote:
>On Jan 3, 10:34 am, Michael Fesser <neti...@gmx.dewrote:
>.oO(Lawrence)
>hi all, while im computing large values the variable value gets
rounded off to the next higher value .How do we stop or prevent this
happening.

How large is "large"? What about a code example?

Micha

$a=$b+$c+$d
where $b=99999999999999
$c=99999999999999
$d=99999999999999
When a number gets too large for a 32-bit integer, PHP switches to floating
point. An IEEE-754 floating point value holds just over 15 digits of
precision. $b, $c and $d fit, but $a does not. Hence, you lose precision.

If you need arbitrary precision mathematics, look at the BCMath functions
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jan 3 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.