Infinity?
Andrew Henrick
ahenrick at nd.edu
Thu Oct 10 00:15:04 UTC 2002
Hello everyone,
I am a new comer to Squeak and I have a few questions. My background in
Smalltalk (and the Squeak version of it) is pathetic so please excuse
my ignorance. Also please let me know if I am posting to the wrong
list. The only real reference I have is "Squeak: A Quick Trip to
ObjectLand." In any case, here they are:
Q1. Is there some way to have the browser colorize and indent on the
fly as I write code? Right now, I just select "colorPrint" and that
formats text that has been accepted by the "system," but is there
anything better that is "built-in"?
Q2. I am confused about Exception handling in Squeak. Were can I find
an adaquate description of how it works. For instance what generates
which exceptions?
Q3. How can I detect an underflow/overflow in the system. This may
seem like an odd question, but it comes in reference to some code that I
found in "Object-Oriented Implementation of Numerical Methods" by
Besset. He was working in Visual Age, so his exception handling is
different, but the idea is to cause an overflow by repetitive
multipilication:
computeLargestNumber
| one floatingRadix fullMantissaNumber |
one _ 1 asFloat.
floatingRadix _ self radix asFloat.
fullMantissaNumber _ one - (floatingRadix * self
negativeMachinePrecision).
largestNumber _ fullMantissaNumber.
[[fullMantissaNumber _ fullMantissaNumber * floatingRadix.
largestNumber _ fullMantissaNumber.
true] whileTrue: [ ].
] when: ExAll do: [:signal | signal exitWith: nil].
I tried using this code and changing the exception handling to an
ifError: message, but that does not work. If i print the largestNumber
to the transcript after each iteration the number eventually becomes
"Infinity", but no exception is thrown. Instead the following seems to
do the trick:
computeLargestNumber
| one floatingRadix fullMantissaNumber |
one _ 1 asFloat.
floatingRadix _ self radix asFloat.
fullMantissaNumber _ one - (floatingRadix * self
negativeMachinePrecision).
[largestNumber _ fullMantissaNumber.
fullMantissaNumber _ fullMantissaNumber * floatingRadix.
fullMantissaNumber isInfinite] whileFalse
Also, I was wondering what the heck Infinity is. If one does a 'Float
inspect' and looks at the 'classPool', they will see that Infinity is a
class variable of Float, but that its value is Infinity?
Thanks,
AKH
--
*******************************************
Andrew Henrick
Department of Aerospace and Mechanical Engineering
University of Notre Dame
http://newton.ame.nd.edu/~ahenrick
Los Alamos National Laboratory
Dynamic eXperimentation Division 2
Phone: 5-1137
Mail Stop: SM C920
"Ah, I know the lion by his paw!"
- Johann Bernoulli after Newton discovered the solution to the
brachistochrone problem
"If we knew what it was we were doing, it would not be called
research, would it?"
- Albert Einstein
"When you say 'I wrote a program that crashed Windows', people just stare at
you blankly and say 'Hey, I got those with the system, *for free*'." -
- Linus Torvalds
*******************************************
More information about the Squeak-dev
mailing list
|