I have done a basic arithmetic calculation and got the answer aaHere is the SmallTalk code in Squeak: Transcript show: 'aa='.Transcript show: 23124234 * 431213; cr. The output is aa=99714703158429971470315842 is a decimal number.What can I do to display a number in any hex I want ??
-- Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
On Monday 23 October 2017 10:40 AM, RedTigerFish wrote:
Transcript show: 'aa='. Transcript show: 23124234 * 431213; cr.
The output is aa=9971470315842 9971470315842 is a decimal number. What can I do to display a number in any hex I want ??
Transcript show: (23124234 * 431213) hex; cr
You can discover such functions by giving an example in Method Finder. For instance 23 is represented as 16r17 in hex, so:
23 . '16r17'
will reveal the method. For any radix, see printStringBase: method.
HTH .. Subbu
Hello, thanks for your answer.
Here is my thinking:
Transcript show: (23124234 * 431213) hex; cr
The above code only displays a decimal in hexadecimal which is base-16. Now I want a decimal number to be displayed in base-17 or 20 or 100 or 250 or any positive integer. How can I do that? Is that possible in Smalltalk?
I tried "Method Finder" and typed in Selector Browser "23 . '17r16' , only to get the warning: no single method does that function.
Any method I can solve this problem ?
-- Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
On Monday 23 October 2017 04:40 PM, RedTigerFish wrote:
Hello, thanks for your answer.
Here is my thinking:
Transcript show: (23124234 * 431213) hex; cr
The above code only displays a decimal in hexadecimal which is base-16. Now I want a decimal number to be displayed in base-17 or 20 or 100 or 250 or any positive integer. How can I do that? Is that possible in Smalltalk?
Yes, with printStringBase: method
Transcript show: ((23124234 * 431213) printStringBase: 17); cr
HTH .. Subbu
Thanks. That is what I want.
But when I type:
Transcript show: ((2423460) printStringBase: 250); cr.
A "MessageNotUnderstood" window pops up.
Is there a maximal base for displaying numbers?
----- Dig, dig where you are, Down below's well. Let those that walk in darkness shout, Down below's hell. -- Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
On Mon, Oct 23, 2017 at 1:27 PM, RedTigerFish chihuyu@gmail.com wrote:
Thanks. That is what I want.
But when I type:
Transcript show: ((2423460) printStringBase: 250); cr.
A "MessageNotUnderstood" window pops up.
Is there a maximal base for displaying numbers?
Yes, the maximum base is 36, because we only use 0-9 and A-Z as digits:
$Z digitValue => 35
For larger bases you would have to invent your own digits.
Even digits beyond F (hexadecimal 15) are non-standard, and are allowed more as a syntactic curiosity than as something with a real application.
The only somewhat commonly used bases are 2, 8, 10, 13, and 16, as far as I know.
- Bert -
On Mon, Oct 23, 2017 at 10:32 AM, Bert Freudenberg bert@freudenbergs.de wrote:
The only somewhat commonly used bases are 2, 8, 10, 13, and 16, as far as
I know.
- Bert -
Hi.
I haven't run across a reason to use base 13. What domain was that in? Just curious, cbc
On Tue, Oct 24, 2017 at 5:14 PM, Chris Cunningham cunningham.cb@gmail.com wrote:
On Mon, Oct 23, 2017 at 10:32 AM, Bert Freudenberg bert@freudenbergs.de wrote:
The only somewhat commonly used bases are 2, 8, 10, 13, and 16, as far
as I know.
- Bert -
Hi.
I haven't run across a reason to use base 13. What domain was that in? Just curious, cbc
The answer is 42.
;)
- Bert -
On Tue, Oct 24, 2017 at 11:25 PM, Bert Freudenberg bert@freudenbergs.de wrote:
On Tue, Oct 24, 2017 at 5:14 PM, Chris Cunningham <cunningham.cb@gmail.com
wrote:
On Mon, Oct 23, 2017 at 10:32 AM, Bert Freudenberg bert@freudenbergs.de wrote:
The only somewhat commonly used bases are 2, 8, 10, 13, and 16, as far
as I know.
- Bert -
Hi.
I haven't run across a reason to use base 13. What domain was that in? Just curious, cbc
The answer is 42.
;)
- Bert -
And Adams swears this was never planned. Pure co-incidence that it worked out that way. Hmmmmmm.....? cheers -ben
On Tue, Oct 24, 2017 at 11:06 PM, Ben Coman btc@openinworld.com wrote:
On Tue, Oct 24, 2017 at 11:25 PM, Bert Freudenberg bert@freudenbergs.de wrote:
On Tue, Oct 24, 2017 at 5:14 PM, Chris Cunningham < cunningham.cb@gmail.com> wrote:
On Mon, Oct 23, 2017 at 10:32 AM, Bert Freudenberg <bert@freudenbergs.de
wrote:
The only somewhat commonly used bases are 2, 8, 10, 13, and 16, as far
as I know.
- Bert -
Hi.
I haven't run across a reason to use base 13. What domain was that in? Just curious, cbc
The answer is 42.
;)
- Bert -
And Adams swears this was never planned. Pure co-incidence that it worked out that way. Hmmmmmm.....? cheers -ben
Yep. For those not yet in on the joke:
In Douglas Adams "Hitchhiker" trilogy the number 42 plays an important role, and at some point it was defined as 6x9. Intended as a joke, it turned out that this is actually correct in base 13, and can be written easily in Smalltalk, but not most other computer languages:
13r6 * 13r9 = 13r42 => true
- Bert -
Hi,
I get the feeling you are asking the wrong question. Can you tell us more about what you are trying to do.
Lou
On Mon, 23 Oct 2017 04:27:15 -0700 (MST), RedTigerFish chihuyu@gmail.com wrote:
Thanks. That is what I want.
But when I type:
Transcript show: ((2423460) printStringBase: 250); cr.
A "MessageNotUnderstood" window pops up.
Is there a maximal base for displaying numbers?
Dig, dig where you are, Down below's well. Let those that walk in darkness shout, Down below's hell.
beginners@lists.squeakfoundation.org