note 493 modified in function.setlocale by derick

From: Date: Tue, 15 Jan 2002 10:27:04 +0000
Subject: note 493 modified in function.setlocale by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-24834@lists.php.net to get a copy of this message
It is written nowhere, that setlocale() can be used for simple mathematical operations like adding, substracting, dividing or multiplying. The code below gives correct results: setlocale(LC_ALL, "pl"); $net = "1234,56"; $gross = "1,22" * $net; printf("gross: %s, net: %s", $gross, $net"); /* Polish VAT tax is 22% */ Result of this code is: gross: 1234,56, net: 1506,1632 So, every one can use his own decimal point for mathematical operations without any error or warning (PHP3.0.3). --was-- It is written nowhere, that setlocale() can be used for simple mathematical operations like adding, substracting, dividing or multiplying. The code below gives correct results: setlocale("LC_ALL", "pl"); $net = "1234,56"; $gross = "1,22" * $net; printf("gross: %s, net: %s", $gross, $net"); /* Polish VAT tax is 22% */ Result of this code is: gross: 1234,56, net: 1506,1632 So, every one can use his own decimal point for mathematical operations without any error or warning (PHP3.0.3). http://www.php.net/manual/en/function.setlocale.php

« previous php.notes (#24834) next »