note 493 modified in function.setlocale by freeman

From: Date: Mon, 23 Feb 2004 04:56:58 +0000
Subject: note 493 modified in function.setlocale by freeman
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-65559@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 (#65559) next »