Greetings,
I'm a high school math teacher implementing a "virtual" version of my state's testing calculator for use in class.
I've gotten fairly far, but I'm now to the point where I have to duplicate the calculator's precision. The calculator can display a maximum of 10 digits, so I need to round everything to 10 digits. I also need something flexible enough that numbers whose integer portion is greater than 10 digits are expressed in scientific notation.
I've made some progress using math context and BigDecimal. Here is my current "display whatever is supposed to be on the calculator" function:
//Utility function for updating the display
public void refresh()
{
MathContext rounder = new MathContext(10);
BigDecimal convertedNumber= new BigDecimal(numberOnDisplay,rounder);
theDisplay.updateNumber(convertedNumber.toString());
}
But I have some problems:
1) Is there some way I can get these to automatically convert to scientific notation, as described above? Right now, I'm planning a soul-crushing amount of string voodoo.
2) Trailing zeros, when they are entered, should be displayed, but not when they are calculated. I figure I'll have to do this manually, but it's worth a hail-mary that some obscure format setting is out there.
That's all I can think of right now. Any help would be appreciated.
-Troy K