I have an unusual request. I know etoys allows the user to view up to 10 decimal places in a number. I was wondering if there was a way to increase this number. I have a project participant who is using etoys with a Vernier pH sensor and he is using calculations that that result in extremely small numbers. I am familiar with programming in Squeak and can alter our project's image if necessary.
------------------------ Wesley Williams Project Assistant USeIT Project
-------------------- m2f --------------------
(from forum) http://forums.squeakland.org/viewtopic.php?p=9562#9562
-------------------- m2f --------------------
On Thu, Jul 16, 2009 at 12:27 PM, USeITWesetoys-dev-forum@squeakland.org wrote:
I have an unusual request. I know etoys allows the user to view up to 10 decimal places in a number. I was wondering if there was a way to increase this number.
Yes, certainly. You can redefine or subclass any object class in the system. Open a code viewer on the object that does the calculation, and take a look at the class of the result. There are 15 or 16 digits of usable precision in IEEE floating point numbers.
I have a project participant who is using etoys with a Vernier pH sensor and he is using calculations that that result in extremely small numbers.
To how many significant digits? Calculations resulting in extremely small numbers are notorious for losing precision. Thus, for example, 1.00001-1.00000 = 0.00001, with only one significant digit remaining, if that.
Your explanation is not adequate, unless you are using fixed-point arithmetic where you should use floating-point. I don't think there has ever been a measurement of anything to better than ten significant figures. Thus, for example,
0.0000000000123
should be written as 1.23E-11, with only three digits of precision.
I am familiar with programming in Squeak and can alter our project's image if necessary.
Wesley Williams Project Assistant USeIT Project
-------------------- m2f --------------------
(from forum) http://forums.squeakland.org/viewtopic.php?p=9562#9562
-------------------- m2f -------------------- _______________________________________________ etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
I was in hurry with the post above, so I kept it brief. I apologize for being unclear, but now I can elaborate. The member in question is using the read out from a pH probe that gives a measurement which is alway between 0 (acid) and 14 (base) which gives 7 digits of precision. He then tried to create a script to calculate the concentration of hydrogen ions [H+]. The formula to calculate that is 10^-pH = [H+]. For a substance that is extremely basic, say a 12.6 on the pH scale, that would result in a concentration of 0.000000000000251. He attempted to use that result in another script and another equation and received a divide-by-zero exception.
I hope that clears up any confusion. Thanks for the prompt response Mr. Cherlin. I will try your solution immediately.
------------------------ Wesley Williams Project Assistant USeIT Project
-------------------- m2f --------------------
(from forum) http://forums.squeakland.org/viewtopic.php?p=9569#9569
-------------------- m2f --------------------
On 16.07.2009, at 23:48, USeITWes wrote:
I was in hurry with the post above, so I kept it brief. I apologize for being unclear, but now I can elaborate. The member in question is using the read out from a pH probe that gives a measurement which is alway between 0 (acid) and 14 (base) which gives 7 digits of precision. He then tried to create a script to calculate the concentration of hydrogen ions [H+]. The formula to calculate that is 10^-pH = [H+]. For a substance that is extremely basic, say a 12.6 on the pH scale, that would result in a concentration of 0.000000000000251. He attempted to use that result in another script and another equation and received a divide-by-zero exception.
I hope that clears up any confusion. Thanks for the prompt response Mr. Cherlin. I will try your solution immediately.
The precision setting only affects the display. However, for some properties there is some rounding going on. Can you provide the script that failed?
- Bert -
At Thu, 16 Jul 2009 17:48:21 -0400, USeITWes wrote:
I was in hurry with the post above, so I kept it brief. I apologize for being unclear, but now I can elaborate. The member in question is using the read out from a pH probe that gives a measurement which is alway between 0 (acid) and 14 (base) which gives 7 digits of precision. He then tried to create a script to calculate the concentration of hydrogen ions [H+]. The formula to calculate that is 10^-pH = [H+]. For a substance that is extremely basic, say a 12.6 on the pH scale, that would result in a concentration of 0.000000000000251. He attempted to use that result in another script and another equation and received a divide-by-zero exception.
I hope that clears up any confusion. Thanks for the prompt response Mr. Cherlin. I will try your solution immediately.
There can be a unexpected truncation somewhere. Yes, please show us your script.
For getting more digits, you could use Text and Labels. In an experimental project I created:
http://dev.laptop.org/~yoshiki/etoys/ph.002.pr
I type the input concentration into the top text (which you may not need). When you click on the light blue rectangle, it calculates the pH from the input, and then calculate back the density and set it into the label below. Note the usage of function tiles like exp and log.
Yes, but this was not obvious even for me:
- We have ln and log, but we only have exp. - The Text's numericValue setter truncates the value. But the Label in the Connectors doesn't. So I resort to use the Label for the read out.
-- Yoshiki
Yes, Yoshiki you are right. He is using a Text and using its numeric value. I have included the project he made. We cheated a little with the scripts, I showed him a little bit of SmallTalk to get the appropriate value. This was only his first week using Etoys.
Are there any plans to add the base 10 exponent or better still an equivalent to the "raisedTo:" method into etoys? Many of the teachers I am working with teach high school math and science and they could sure use that capability. If not, perhaps you can direct me where I could add such a feature in my image.
Wesley Williams[/img]
------------------------ Wesley Williams Project Assistant USeIT Project
-------------------- m2f --------------------
(from forum) http://squeakland.org/forums/viewtopic.php?p=9633#9633
-------------------- m2f --------------------
Attachments: http://squeakland.org/forums//files/acids_and_bases004_100.zip
At Mon, 20 Jul 2009 12:43:24 -0400, USeITWes wrote:
Yes, Yoshiki you are right. He is using a Text and using its numeric value. I have included the project he made. We cheated a little with the scripts, I showed him a little bit of SmallTalk to get the appropriate value. This was only his first week using Etoys.
Unfortunately, the project contains some USeIT specific things and couldn't open it (but that is ok; you explained what he did). And text morph shouldn't round numbers.
Are there any plans to add the base 10 exponent or better still an equivalent to the "raisedTo:" method into etoys? Many of the teachers I am working with teach high school math and science and they could sure use that capability. If not, perhaps you can direct me where I could add such a feature in my image.
The problem with raisedTo: is that the function would require two arguments, and it is pretty much beyond what Etoys provides.
However, adding a new one-argument function to the function tile is relatively easy. You add a line that looks like:
(exp10 exp10 'exponential (10 to the power of the argument)')
in StandardScriptingSystem>>tableOfNumericFunctions, and define a method for a Number that looks like:
exp10 ^ 10 raisedTo: self.
and that is it.
-- Yoshiki
etoys-dev@lists.squeakfoundation.org