0
Good afternoon , I’m having trouble calculating percentage, but the error does not occur in the mile up, anyone has any idea what may be?
var cost_value = $('#cost_value').val().replace('.', '').replace(',', '.');
var unitary_value = parseFloat(cost_value) + (parseFloat(cost_value) / 100 *
50.00);
console.log(unitary_value);
console.log(number_format(unitary_value, 2, ',', '.'));
Xenon
cost_value entrada:500000.00
unitary_value saida:750.000,00
cost_value entrada:5000.000.00
unitary_value saida:7.500,00
Probably related: Javascript floating point account realization with absolute precision
– Icaro Martins
Probably related: Why when adding two values to decimals the result is not exact?
– Icaro Martins
What mistake? It would be interesting [Edit] the question by placing some example values, what is the desired result and what is the result you got (and/or the error message, since you said an error occurs - but didn’t say which one)
– hkotsubo
changed a look at the exit
– Junior Ramoty