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 _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
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 _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Dig, dig where you are,
Down below's well. Let those that walk in darkness shout, Down below's hell. |
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? Transcript show: ((23124234 * 431213) printStringBase: 17); cr HTH .. Subbu _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
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 _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Dig, dig where you are,
Down below's well. Let those that walk in darkness shout, Down below's hell. |
Thanks. That is what I want. 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 - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by RedTigerFish
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 <[hidden email]> 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. Louis LaBrunda Keystone Software Corp. SkypeMe callto://PhotonDemon _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Bert Freudenberg
On Mon, Oct 23, 2017 at 10:32 AM, Bert Freudenberg <[hidden email]> wrote: Hi.
I haven't run across a reason to use base 13. What domain was that in? Just curious, cbc _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
The answer is 42. ;) - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On Tue, Oct 24, 2017 at 11:25 PM, Bert Freudenberg <[hidden email]> wrote:
And Adams swears this was never planned. Pure co-incidence that it worked out that way. Hmmmmmm.....? cheers -ben _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
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 - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |