Jump to content

help with float numbers in php


satish.mumbai

Recommended Posts

Hello everyone,

 

Here's something that seems very simple, but has been bothering me for the past few hours !

 

The following code in php

$a = 62745.15;
$b = 64293.6;
$c = 1548.45;
$d = $b - $a - $c;
var_dump($a);
var_dump($b);
var_dump($c);
var_dump($d);

 

gives the following output :

 

float(62745.15)

float(64293.60)

float(1548.45)

float(-2.955857780762E-12)

 

 

My questions :

1. Why does the value of $d not simply come to "float(0)" ??

2. What can I do to get the value of "float(0)" for the calculation as shown in the code above ?

 

Thanks in advance for all your replies.

 

regards,

Satish.

 

Link to comment
https://forums.phpfreaks.com/topic/217113-help-with-float-numbers-in-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.