One way to find out is like so...
if (!isNaN(parseInt(myThingInStringFormat))) {
var useMeDownstream = parseInt(ahNewMeterValue);
Floats (as strings) will be rounded to integers in this approach. A good way to check if you may cleanly round what might be a float to an integer without dropping anything but zeros is:
var testing = parseFloat(ahNewMeterValue);
if (testing % 1 == 0) {
alert('precision means nothing');
} else {
alert('precision matters');
}
No comments:
Post a Comment