Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decimal type in php

Tags:

php

Does PHP have Decimal(±1.0 × 10−28 to ±7.9 × 1028) data type?

like image 666
Neir0 Avatar asked Jul 14 '10 07:07

Neir0


1 Answers

The BC Math extension implements arbitrary-precision decimal math:

$a = '0.1';
$b = '0.2';
echo bcadd($a, $b);     // prints 0.3

(From The Floating-Point Guide)

like image 99
Michael Borgwardt Avatar answered Oct 06 '22 16:10

Michael Borgwardt