php - why (int) ( 307.03 * 100) = 30702 -


this question has answer here:

today coworker stumbled on this:

$s = floatval("307.03"); $s = $s * 100;  echo intval($s); //30702 

float value or round($s) return 30703 expected.

i guess it's problem connected float int approximation why happen ?

the float val stored 307.02999 or intval truncate number, no rounding, hence 30702.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -