note 106367 added to function.floatval

From: Date: Mon, 31 Oct 2011 15:26:21 +0000
Subject: note 106367 added to function.floatval
Groups: php.notes 
Request: Send a blank email to php-notes+get-184260@lists.php.net to get a copy of this message
To view the very large and very small numbers (eg from a database DECIMAL), without displaying scientific notation, or leading zeros. FR : Pour afficher les très grand et très petits nombres (ex. depuis une base de données DECIMAL), sans afficher la notation scientifique, ni les zéros non significatifs. <?php function floattostr( $val ) { preg_match( "#^([\+\-]|)([0-9]*)(\.([0-9]*?)|)(0*)$#", trim($val), $o ); return $o[1].sprintf('%d',$o[2]).($o[3]!='.'?$o[3]:''); } ?> <?php echo floattostr("0000000000000001"); echo floattostr("1.00000000000000"); echo floattostr("0.00000000001000"); echo floattostr("0000.00010000000"); echo floattostr("000000010000000000.00000000000010000000000"); echo floattostr("-0000000000000.1"); echo floattostr("-00000001.100000"); // result // 1 // 1 // 0.00000000001 // 0.0001 // 10000000000.0000000000001 // -0.1 // -1.1 ?> ---- Server IP: 195.221.21.36 Probable Submitter: 80.11.139.248 ---- Manual Page -- http://www.php.net/manual/en/function.floatval.php Edit -- https://master.php.net/note/edit/106367 Del: integrated -- https://master.php.net/note/delete/106367/integrated Del: useless -- https://master.php.net/note/delete/106367/useless Del: bad code -- https://master.php.net/note/delete/106367/bad+code Del: spam -- https://master.php.net/note/delete/106367/spam Del: non-english -- https://master.php.net/note/delete/106367/non-english Del: in docs -- https://master.php.net/note/delete/106367/in+docs Del: other reasons-- https://master.php.net/note/delete/106367 Reject -- https://master.php.net/note/reject/106367 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184260) next »