Problems With Significant Digits / Decimal Places
It was so nice to have MMF2 be able to set the number of decimal places in a counter. But there is a problem.
I want to then use the counter with, let's say, two decimal places to multiply another number. No matter what I do, the original counter with the two decimal places uses the number with more decimal places. This leads to a large enough difference in the answers that it is hard to a check student answers and show the students the correct calculation.
I tried to get the number with the two decimal places by using a string or another counter. In all cases I get the number with many more decimal places.
Any suggestions appreciated.
Steve
Re: Problems With Significant Digits / Decimal Places
I guess this question is not on the top of everyone's list. I don't need the present counter setup to be changed - just a way to get the number that is rounded and set to a certain number of decimal places so I can use it somewhere else. Otherwise I have to go through using the parsar object and / or a number of calculations to do the rounding and trimming.
Is there any way to get this number? It's frustrating, since the number is sitting there visible on the screen but I can't get it!
Steve
Re: Problems With Significant Digits / Decimal Pla
Hmm: Number to string and back seems the best solution for me in this case. Full control ^^
Another solution. You need fixed 2 decimal places? Why not multiply both values with 100, work with integers, and divide through 100.0 when done?
Re: Problems With Significant Digits / Decimal Pla
Yeah, I tried that. But when you take the number to string, it takes all of the decimal places, not just the number you selected for the counter.
Yes, I could write code to round and make the correct number of decimal places, but that's what I'm trying to avoid. No big deal for a single counter, but when you've got a lot of them, it starts to eat up time and leads to possible bugs.
Thanks for the suggestions,
Steve
Re: Problems With Significant Digits / Decimal Pla
Hmm, what about working with integers in general, and just display the decimals ones where necessary?
Re: Problems With Significant Digits / Decimal Pla
Steve,
Decimals in MMF are very sketchy last i used them. You really want to stay away from them where possible. Multiplying by 100 seems like a good idea.
When I had my questions on decimals even some of the staff didn't know how it worked or more importantly, why it didn't :D
Re: Problems With Significant Digits / Decimal Pla
The_Alee, we have added lots of new features since your post. ;)
Re: Problems With Significant Digits / Decimal Pla
Tiles,
Integers are nice and easy but almost all of the calculations in high school and college math and science require decimals.
STeve
Re: Problems With Significant Digits / Decimal Pla
Hmm, Yves, what's the official solution for this case then? How would you solve it?
drnebula, i know. It is just for this special case where i personally would use integers and transform them back to decimals then.
Re: Problems With Significant Digits / Decimal Pla
The way it works now has definite advantages in that the calculations use all of the decimal places as they should and the answer only is shown with a set number of decimal places.
Tiles
Please remember that I am quite often doing multiple sequential caluclations. In other word, I am asking students to do calulations with many multiplications and divisions. And then to use those calulated values to do further calculations. Hopefully, you can see how helpful the added ability to round and set decimal places can be in checking these calculations.
This is a difficult issue for anyone trying to have students do calculations and check them in an educational application. Do the students round off and use the rounded values or do they continue calculations keeping all of the decimal places. The differences between these two methods turn out to be much greater than I would have guessed.
What would be the best solution, from my point of view, would be for an action (available when you go to get a counter value) that would allow a counter to be set to to the "shown value", or counter value that is rounded off and set to a number of decimal places. That value must be readilly available since it is now being displayed on the screen.
Hope you understand what I am trying to say.
STeve