Large Numbers in Smalltalk

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

Large Numbers in Smalltalk

Postby gsharma84 » Fri Feb 05, 2010 12:52 am

HI,
I typed a very large number and when I inspected it, it came out to be a Large Number Object. In Java I guess the number is converted into exponential notation, not sure though.
My question is how does Smalltalk create such large numbers? Though the code is there, but would be better if one can direct me to a doc or so. I want to explore the architectural differences also..
Last edited by gsharma84 on Fri Feb 05, 2010 12:53 am, edited 1 time in total.
gsharma84
 
Posts: 16
Joined: Mon Dec 21, 2009 8:20 pm

Re: Large Numbers in Smalltalk

Postby gsharma84 » Fri Feb 05, 2010 12:53 am

I'm using VA Smalltalk 7.5.2
gsharma84
 
Posts: 16
Joined: Mon Dec 21, 2009 8:20 pm

Re: Large Numbers in Smalltalk

Postby marten » Fri Feb 05, 2010 2:56 am

Whenever a calculation is done and the result might fit into a SmallInteger instance - you get a SmallInteger instance. Otherwise a LargeInteger is created. As you might notice, LargeInteger class is defined as "variableLongSubclass ..." the values therefore are stored in an array holding "long" values - all that stored within the instance.

How many long words the instace needs to store its value can be retrieved by calling "#size" against the instance and the single values can be retrieved by executing aLargeIntegerInstance basicAt: anIndex, where 0 < anIndex <= aLargeIntegerInstance size.

Marten

gsharma84 wrote:HI,
I typed a very large number and when I inspected it, it came out to be a Large Number Object. In Java I guess the number is converted into exponential notation, not sure though.
My question is how does Smalltalk create such large numbers? Though the code is there, but would be better if one can direct me to a doc or so. I want to explore the architectural differences also..
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest