0

I know, I know, one of the big advantages of PHP is that the variables in PHP don't take typecasting but instead any variable can hold any data. Thing is, for something I'm trying right now I need the ability to cast. I'm trying to add together financial values drawn from a database, which means they're all floating-point with two significant digits after the decimal. Problem is, actually doing addition on them seems to deal with integer addition; if the values both end in .*0, then any zeroes after the decimal point are eliminated from the value before it gets displayed on the resulting page. Is there any way in PHP to code for a financial numeric typecast, or am I going to have to hack around it with stringlength comparisons and artifical trailing zeroes?

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by php_daemon
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.