note 81416 added to language.types.float

From: Date: Wed, 27 Feb 2008 09:18:51 +0000
Subject: note 81416 added to language.types.float
Groups: php.notes 
Request: Send a blank email to php-notes+get-136523@lists.php.net to get a copy of this message
Just another note about the locales. Consider the following code: <?php // in polish locale decimal separator is "," setlocale(LC_ALL, "pl_PL"); $a = 5/2; echo (float)(string)$a; /// prints "2", so the decimal part is dropped ?> This causes very serious problems in my opinion. In some locale combination the typecasting can be destructive. Maybe when locale decimal separator is ",", then (float)"2,5" should be recognized as "two and a half"? Anyway - bare that in mind and be very careful when casting floats to strings and back. ---- Server IP: 82.177.164.100 Probable Submitter: 87.204.27.51 ---- Manual Page -- http://www.php.net/manual/en/language.types.float.php Edit -- https://master.php.net/note/edit/81416 Del: integrated -- https://master.php.net/note/delete/81416/integrated Del: useless -- https://master.php.net/note/delete/81416/useless Del: bad code -- https://master.php.net/note/delete/81416/bad+code Del: spam -- https://master.php.net/note/delete/81416/spam Del: non-english -- https://master.php.net/note/delete/81416/non-english Del: in docs -- https://master.php.net/note/delete/81416/in+docs Del: other reasons-- https://master.php.net/note/delete/81416 Reject -- https://master.php.net/note/reject/81416 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136523) next »