php float轉int的坑

一般這種情況在實際額工作中 涉及到價格會出現意想不到的bug 如果 你非要傳一個 float  價格(2位小數) 且做了乘積之後需要轉爲int(奇怪的需求) intval(39.80*100) = 3979 intval(round(floatval($value) * 100)) = 3980
相關文章
相關標籤/搜索