Re: [Pharo-project] Another stupid question

2013-02-16 Thread stephane ducasse
so could you write two tests and submit a slice so that we improve the system Stef convertFromBase: sourceBase to: targetBase Convert the receiver (who has to represent a number string) from the given source base to the given target base ''

Re: [Pharo-project] Another stupid question

2013-02-15 Thread Henrik Johansen
On Feb 15, 2013, at 1:51 AM, Benjamin wrote: On Feb 15, 2013, at 1:40 AM, Torsten Bergmann asta...@gmx.de wrote: This was just an example to play with since you asked for a #convertFromBase:to: method in your original mail and one cant provide such a method on Number. Your original

Re: [Pharo-project] Another stupid question

2013-02-15 Thread Sven Van Caekenberghe
On 15 Feb 2013, at 11:11, Henrik Johansen henrik.s.johan...@veloxit.no wrote: On Feb 15, 2013, at 1:51 AM, Benjamin wrote: On Feb 15, 2013, at 1:40 AM, Torsten Bergmann asta...@gmx.de wrote: This was just an example to play with since you asked for a #convertFromBase:to: method in your

Re: [Pharo-project] Another stupid question

2013-02-15 Thread Benjamin
On Feb 15, 2013, at 11:24 AM, Sven Van Caekenberghe s...@stfx.eu wrote: On 15 Feb 2013, at 11:11, Henrik Johansen henrik.s.johan...@veloxit.no wrote: On Feb 15, 2013, at 1:51 AM, Benjamin wrote: On Feb 15, 2013, at 1:40 AM, Torsten Bergmann asta...@gmx.de wrote: This was just an

Re: [Pharo-project] Another stupid question

2013-02-15 Thread Henrik Sperre Johansen
On 15.02.2013 11:29, Benjamin wrote: On Feb 15, 2013, at 11:24 AM, Sven Van Caekenberghe s...@stfx.eu wrote: On 15 Feb 2013, at 11:11, Henrik Johansen henrik.s.johan...@veloxit.no wrote: On Feb 15, 2013, at 1:51 AM, Benjamin wrote: On Feb 15, 2013, at 1:40 AM, Torsten Bergmann

[Pharo-project] Another stupid question

2013-02-14 Thread Benjamin
Hi guys, I know it sounds stupid but how do I convert numbers from one base to another ? I found 3 printStringBase: 2 - '11' But I would like something like 11 convertFromBase: 2 to: 10 - 3 The Finder did help me about this one so I ask here :) Thanks in advance, Ben

Re: [Pharo-project] Another stupid question

2013-02-14 Thread jannik.laval
Hi Ben, use that: 2r11 printStringBase: 10 - 3 16r11 printStringBase: 10 -17 Cheers, Jannik On Feb 14, 2013, at 10:05 PM, Benjamin benjamin.vanryseghem.ph...@gmail.com wrote: Hi guys, I know it sounds stupid but how do I convert numbers from one base to another ? I found 3

[Pharo-project] Another stupid question

2013-02-14 Thread Torsten Bergmann
Hi Benjamin, from your example I guess you know how to convert from decimal (base 10) to binary (base 2): 9 printStringBase: 2 gives you the binary representation/bit string: '1001'. If I understand your post correctly you want the other way around and you want to get the decimal value

[Pharo-project] Another stupid question

2013-02-14 Thread Torsten Bergmann
Add this method to String class: convertFromBase: sourceBase to: targetBase Convert the receiver (who has to represent a number string) from the given source base to the given target base '' convertFromBase: 16 to: 2

Re: [Pharo-project] Another stupid question

2013-02-14 Thread Sven Van Caekenberghe
On 14 Feb 2013, at 22:05, Benjamin benjamin.vanryseghem.ph...@gmail.com wrote: Hi guys, I know it sounds stupid but how do I convert numbers from one base to another ? I found 3 printStringBase: 2 - '11' But I would like something like 11 convertFromBase: 2 to: 10 - 3 The

Re: [Pharo-project] Another stupid question

2013-02-14 Thread Sven Van Caekenberghe
On 15 Feb 2013, at 00:09, Torsten Bergmann asta...@gmx.de wrote: convertFromBase: sourceBase to: targetBase Convert the receiver (who has to represent a number string) from the given source base to the given target base '' convertFromBase:

[Pharo-project] Another stupid question

2013-02-14 Thread Torsten Bergmann
Sven wrote: So something like this should work: (Integer readFrom: 'FF' base: 16) printStringBase: 2 Integer readFrom: 'FF' will not work since #readFrom: expects a string in decimal representation and 'FF' is hexadecimal. It also wont work for large numbers due to sending it to Integer.

Re: [Pharo-project] Another stupid question

2013-02-14 Thread Sven Van Caekenberghe
Euh, sure this works: (Number readFrom: 'FF' base: 16) printStringBase: 2 Number class#readFrom:base: Integer class#readFrom:base: On 15 Feb 2013, at 00:26, Torsten Bergmann asta...@gmx.de wrote: Sven wrote: So something like this should work: (Integer readFrom: 'FF' base: 16)

[Pharo-project] Another stupid question

2013-02-14 Thread Torsten Bergmann
Euh, sure this works: (Number readFrom: 'FF' base: 16) printStringBase: 2 Yes, one has to use Number instead of Integer and #readFrom:base: #readFrom: works too if you already have the string in source base representation, e.g. '16rFF'. The timing is good - currently work on the literal

Re: [Pharo-project] Another stupid question

2013-02-14 Thread Benjamin
Thank you guys :) I feel a little less dumb :) (even if it's not really natural for me to have this behaviour on string but ^^) Ben On Feb 15, 2013, at 12:33 AM, Sven Van Caekenberghe s...@stfx.eu wrote: Euh, sure this works: (Number readFrom: 'FF' base: 16) printStringBase: 2 Number

[Pharo-project] Another stupid question

2013-02-14 Thread Torsten Bergmann
This was just an example to play with since you asked for a #convertFromBase:to: method in your original mail and one cant provide such a method on Number. Your original request 11 convertFromBase: 2 to: 10 may work - but it wont work for hex values: FF convertFromBase: 16 to: 10 then FF

Re: [Pharo-project] Another stupid question

2013-02-14 Thread Benjamin
On Feb 15, 2013, at 1:40 AM, Torsten Bergmann asta...@gmx.de wrote: This was just an example to play with since you asked for a #convertFromBase:to: method in your original mail and one cant provide such a method on Number. Your original request 11 convertFromBase: 2 to: 10 may work