Afficher un message
Vieux 07/01/2008, 12h20   #1
Cyril Chacko
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Float Value Parse Problem

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 .

Regards.

Cyril Chacko
--
Beauty lies in the eye of the beholder. Make sure they are on you.
  Réponse avec citation
 
Page generated in 0,05414 seconds with 9 queries