View Full Version : Javascript Calculator Significant Figures

12-01-2006, 01:39 PM
Basically, i'm in 11th grade and i just got an assignment where im supposed to display 5 prompts, have the user type in numbers, the numbers multiply, and then these numbers are to be displayed in signifcant figures.

The first part is cake. The numbers multiply and everything, and I discovered a function called [var].toPrecision() which gives me significant figures according to the number I ask manually.

Unfortunatly the assignment is much more technically than that. If for example i multiply 1.2222222 * 100 the signifcant figures should end at the lowest decimal, making the answer 122. And if i multiply 33.33 * 33.33 then the lowest decimal is to the hundreths place and the answer is 99.99.

Can someone please help me with this?? I know very little about javascript and it is the first language i have learned. Is there a master out there who can offer an approach to this to a newbie?

12-01-2006, 04:07 PM
There is already a javascript built-in for setting a number to a certain amount of decimal places.


Other than that, I'm not sure what you're asking. Can you be a little more clear on the assignment?