SineCosine
I'm still looking for my Tangent
- Reaction score
- 77
Umm..
Yea, I was just making some random vernier calipers out of javascript because explaining how to use them to some people is just difficult =/
So, making it was easy.
It works fine and all, nothing wrong with that script.
The problem is these 'buttons' I added that will increase the reading by 0.01cm.
The button:
(Nothing wrong here)
The script:
So, there are 2 ways for the user to increase the reading of the vernier calipers.
Using the text-input field works with no errors.
Clicking the button results in the weird bug where [lJASS]0.09 + 0.01 = 0.0:[/lJASS]
But only for values with the number 9 at it's hundredths-place.
Weird =/
Anyone know what's wrong?
PS: It won't work if I do this:
Yea, I was just making some random vernier calipers out of javascript because explaining how to use them to some people is just difficult =/
So, making it was easy.
It works fine and all, nothing wrong with that script.
The problem is these 'buttons' I added that will increase the reading by 0.01cm.
The button:
(Nothing wrong here)
Code:
<input type="button" value=">>>>" onClick="increaseReading()">
<input type="text" value="0.00" id="reading">
<div id="Vernier"></div>
The script:
Code:
var observedReading = 0.00;
function increaseReading () {
var r = document.getElementById('reading');
observedReading = (parseFloat(r.value, 10) + 0.01).toFixed(2);
r.value = observedReading;
createVernier(document.getElementById('Vernier'), observedReading);
}
So, there are 2 ways for the user to increase the reading of the vernier calipers.
- Entering a value in the text-input field
- Clicking the '>>>>' button
Using the text-input field works with no errors.
Clicking the button results in the weird bug where [lJASS]0.09 + 0.01 = 0.0:[/lJASS]
But only for values with the number 9 at it's hundredths-place.
Code:
//I tried this
alert((0.09 + 0.01).toFixed(2));
//The result is -> 0.0:
Weird =/
Anyone know what's wrong?
PS: It won't work if I do this:
Code:
createVernier(someDiv, (0.09 + 0.01);
function createVernier (parentDiv, reading) {
alert(reading.toFixed(2));
//It'll still return 0.0:
}