php income twine reworking integer error


i have little financial concentration php front finish mysql behind end. i have ancient prejudices, i store income values mysql an integer cents. html forms grant quarrel dollar values, "156.64" i php modify cents following i store cents database.



i have duty both cleans dollar value form, translates cents. i frame streamer text, i frame trailing text, i greaten 100 modify an integer. final step is



$cents = (integer) ($dollars * 100);



this works glorious roughly everything, solely unequivocally few values '156.64' consistently translates 15663 cents. since does this?



if i this:



$cents = (integer) ($dollars * 100 + 0.5);



then consistently works. since i need supplement rounding value?



also, prejudices storing income amounts integers floating indicate values, longer needed? difficult boyant calculations furnish simply lifeless accurate income values adequate retaining 100% accurate accounting?



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

using mvc, should hoop communication between views? between models?