PHP returns incorrect total

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
MeroD
New php-forum User
New php-forum User
Posts: 53
Joined: Wed Oct 10, 2012 12:14 am

Wed Nov 07, 2012 10:51 pm

Floating-point data types like DOUBLE are approximate and do not represent exact numbers.

number_format($...total) may give you better results.

johnj
php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Thu Nov 08, 2012 8:23 am

It is better to use the bcmath function for math calculations.
http://php.net/manual/en/book.bc.php

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests