Variable typing in PHP?

Reply

Join Date: Aug 2006
Posts: 999
Reputation: EnderX is an unknown quantity at this point 
Solved Threads: 1
EnderX EnderX is offline Offline
Posting Shark

Variable typing in PHP?

 
0
  #1
Feb 1st, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Variable typing in PHP?

 
0
  #2
Feb 1st, 2007
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 138
Reputation: php_daemon is an unknown quantity at this point 
Solved Threads: 2
php_daemon php_daemon is offline Offline
Junior Poster

Re: Variable typing in PHP?

 
0
  #3
Feb 2nd, 2007
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1552 | Replies: 2
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC