Float Value Parse Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have created a class and passing a float value to a method in it. I
have checked the the argument values in the method. The passed
argument has the proper value. However, on any arithmetic operation
the float as a whole is rounded off.

System Information :
   Operating System : Windows
   PHP Version           : PHP Version 5.2.4
   Web Server            : Microsoft-IIS/5.0

Code Snippet :
<?php

class Order extends JObject {
	var $_name = 'Order';
	var $id = null;
	var $ord_desc = null;
	var $date = null;
	var $total_amt = 0;
	var $scheme = null;
	var $shipping = 0.00;
	var $service_tax = 0.00;
	var $other = 0.00;
	var $discount = 0.00;
	var $discount_percentage = 0.00;
	var $qty = 0;
	var $uid = 0;
	var $payment_mode = 0;
	var $deliverydt = null;
	var $paymentstatus = 0;
	var $_amount = 0.00;
	var $recordstatus = 0;

	function addItem( $qty, $price, $discount = 0 ) {
		$this->qty += $qty;
		$this->total_amt += ( $price * $qty )- $discount;
		return true;
	}

}
?>

-----
On Caliing the function as
$order->addItem( 1, 2555.00, 0 );
            $price = 2555.00,          String Data Type
            $price * $qty = 3000,    Double Data Type

$order->addItem( 1, 3005.00, 0 );
            $price = 3005.00,          String Data Type
            $price * $qty = 3000,    Double Data Type

Please let me know if anything else is required. Thanks for the help.

Regards.

Cyril Chacko
-- 
Beauty lies in the eye of the beholder. Make sure they are on you.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux