Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,884 questions

51,810 answers

573 users

How to use bcadd() BC Math Function to add two arbitrary precision numbers in PHP

1 Answer

0 votes
$a = '3.6759';
$b = '7';
 
echo bcadd($a, $b)    . "<br>";  // 10
echo bcadd($a, $b, 1) . "<br>";  // 10.6
echo bcadd($a, $b, 3) . "<br>";  // 10.675
echo bcadd($a, $b, 4) . "<br>";  // 10.6759
echo bcadd($a, $b, 5) . "<br>";  // 10.67590
echo bcadd($a, $b, 6) . "<br>";  // 10.675900

/*
run: 

10
10.6
10.675
10.6759
10.67590
10.675900

*/


answered Sep 25, 2014 by avibootz
edited Jun 1, 2016 by avibootz

Related questions

1 answer 170 views
1 answer 199 views
1 answer 167 views
1 answer 192 views
192 views asked Sep 25, 2014 by avibootz
1 answer 194 views
194 views asked Sep 25, 2014 by avibootz
1 answer 291 views
291 views asked Sep 25, 2014 by avibootz
...