My script calculates weights of products. Full box weights 25.2KG. Each item weights 4.2KG making 6 items full box.
I'm chekcing with Javascript if box.
alert(jsonData.total_weight + ' % ' + fullpackweight + ' = ' + jsonData.total_weight % fullpackweight);
if(jsonData.total_weight % fullpackweight == 0) {
$('#fill_status').hide();
$('#fill_status i').html('OK ' + jsonData.total_weight);
} else {
$('#fill_status').show();
$('#fill_status i').html('NOT OK ' + jsonData.total_weight);
}
Alert box from top of script gives following results:
25.2 % 25.2 = 0
50.4 % 25.2 = 0
75.6 % 25.2 = 25.199999999999996 (WHY?)
100.8 % 25.2 = 0
126 % 25.2 = 3.552713678800501e-15 (WHY?)
Anyone whou could explain this behaviour?