Bug #17611 Updated: float takes away zeros at the end

From: Date: Thu, 06 Jun 2002 12:02:56 +0000
Subject: Bug #17611 Updated: float takes away zeros at the end
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-9631@lists.php.net to get a copy of this message
ID: 17611 Updated by: mfischer@php.net Reported By: fredrik.soderquist@ks.se -Status: Closed +Status: Bogus Bug Type: Math related Operating System: Linux: Debian potato PHP Version: 4.2.1 Previous Comments: ------------------------------------------------------------------------ [2002-06-06 07:19:02] fredrik.soderquist@ks.se I sorry for this bogus bug-report. I know understand the picture. You guys can delete this bug-report if you want. It's seemes sooo obvious now! I fell so ashamed, i should have looked up how other languages treat float first. ------------------------------------------------------------------------ [2002-06-06 04:23:23] sander@php.net It doesn't remove them, it just doesn't display them by default. Use printf() & co or number_format(). ------------------------------------------------------------------------ [2002-06-05 08:41:03] fredrik.soderquist@ks.se Sample script: <?php $a = "5.00"; $b = (float) $a; //returns 5 $c = (double) $a; //returns 5 $d = (real) $a; //returns 5 settype($a,"float"); //$a now returns 5 (gettype($a) returns double) $e = "5.01"; $f = (float) $e; //returns 5.01 (gettype($f) returns double) ?> My configure line: ./configure --prefix=/etc/php --exec-prefix=/etc/php/exec --with-sybase=/etc/freetds --with-apxs2=/etc/apache/bin/apxs --with-cpdflib=/usr/local/lib --enable-calender Comment: In any ordanary programming langauge "float" always is a specified amount of numbers. Float in PHP seemes to remove the zeros. When I convert an interger (or any other type) to a floating number it should add the amount of zeros that are specified for the language. Ex: int a = 3; float a; a becomes 3.0. You should at least be able to convert from a string such as "5.000000" to a float without it removing the zeros after the didget! ------------------------------------------------------------------------ [2002-06-05 08:40:26] fredrik.soderquist@ks.se Sample script: <?php $a = "5.00"; $b = (float) $a; //returns 5 $c = (double) $a; //returns 5 $d = (real) $a; //returns 5 settype($a,"float"); //$a now returns 5 (gettype($a) returns double) $e = "5.01"; $f = (float) $e; //returns 5.01 (gettype($f) returns double) ?> My configure line: ./configure --prefix=/etc/php --exec-prefix=/etc/php/exec --with-sybase=/etc/freetds --with-apxs2=/etc/apache/bin/apxs --with-cpdflib=/usr/local/lib --enable-calender' Comment: In any ordanary programming langauge "float" always is a specified amount of numbers. Float in PHP seemes to remove the zeros. When I convert an interger (or any other type) to a floating number it should add the amount of zeros that are specified for the language. Ex: int a = 3; float a; a becomes 3.0. You should at least be able to convert from a string such as "5.000000" to a float without it removing the zeros after the didget! ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17611&edit=1

« previous php.bugs (#9631) next »