About Fraction and parentheses

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

About Fraction and parentheses

SergeStinckwich
I have one question about Fraction.

When I print a fraction like 1/2 in the Playground I obtain (1/2) and
when I inspect I obtain ((1/2)). Why do we need all these parentheses
?

I didn't try with a current Pharo 6.0 image, because my bandwidth is
quite limited right now (Vietnam).

--
Serge Stinckwich
UCBN & UMI UMMISCO 209 (IRD/UPMC)
Every DSL ends up being Smalltalk
http://www.doesnotunderstand.org/

Reply | Threaded
Open this post in threaded view
|

Re: About Fraction and parentheses

Stephane Ducasse-3
Hi serge

the printing should be normal because like that you are ready to type 
1/3 + 2/3 and get 1. 
Now I do not get why you get ((1/2)) thanks for reporting it.

Stef

On Mon, Dec 19, 2016 at 9:08 AM, Serge Stinckwich <[hidden email]> wrote:
I have one question about Fraction.

When I print a fraction like 1/2 in the Playground I obtain (1/2) and
when I inspect I obtain ((1/2)). Why do we need all these parentheses
?

I didn't try with a current Pharo 6.0 image, because my bandwidth is
quite limited right now (Vietnam).

--
Serge Stinckwich
UCBN & UMI UMMISCO 209 (IRD/UPMC)
Every DSL ends up being Smalltalk
http://www.doesnotunderstand.org/


Reply | Threaded
Open this post in threaded view
|

Re: About Fraction and parentheses

Sven Van Caekenberghe-2

> On 19 Dec 2016, at 22:00, Stephane Ducasse <[hidden email]> wrote:
>
> Hi serge
>
> the printing should be normal because like that you are ready to type
> 1/3 + 2/3 and get 1.

No, not at all:

1/3 + 2/3

  "(7/9)"

These are all just binary messages evaluated left to right, like this:

((1/3) + 2)/3  

  "(7/9)"

That is why you need the parenthesis in certain contexts.
Now adding two of them is definitively wrong.

(1/3) + (2/3)

  "1"

(The first parenthesis are not needed, btw).

> Now I do not get why you get ((1/2)) thanks for reporting it.
>
> Stef
>
> On Mon, Dec 19, 2016 at 9:08 AM, Serge Stinckwich <[hidden email]> wrote:
> I have one question about Fraction.
>
> When I print a fraction like 1/2 in the Playground I obtain (1/2) and
> when I inspect I obtain ((1/2)). Why do we need all these parentheses
> ?
>
> I didn't try with a current Pharo 6.0 image, because my bandwidth is
> quite limited right now (Vietnam).
>
> --
> Serge Stinckwich
> UCBN & UMI UMMISCO 209 (IRD/UPMC)
> Every DSL ends up being Smalltalk
> http://www.doesnotunderstand.org/
>
>


Reply | Threaded
Open this post in threaded view
|

Re: About Fraction and parentheses

Stephane Ducasse-3
I think that I know that :)
And this is why I mentioned that if you print 1/3 it prints (1/3) so that we can continue typing + (2/3)

On Mon, Dec 19, 2016 at 11:02 PM, Sven Van Caekenberghe <[hidden email]> wrote:

> On 19 Dec 2016, at 22:00, Stephane Ducasse <[hidden email]> wrote:
>
> Hi serge
>
> the printing should be normal because like that you are ready to type
> 1/3 + 2/3 and get 1.

No, not at all:

1/3 + 2/3

  "(7/9)"

These are all just binary messages evaluated left to right, like this:

((1/3) + 2)/3

  "(7/9)"

That is why you need the parenthesis in certain contexts.
Now adding two of them is definitively wrong.

(1/3) + (2/3)

  "1"

(The first parenthesis are not needed, btw).

> Now I do not get why you get ((1/2)) thanks for reporting it.
>
> Stef
>
> On Mon, Dec 19, 2016 at 9:08 AM, Serge Stinckwich <[hidden email]> wrote:
> I have one question about Fraction.
>
> When I print a fraction like 1/2 in the Playground I obtain (1/2) and
> when I inspect I obtain ((1/2)). Why do we need all these parentheses
> ?
>
> I didn't try with a current Pharo 6.0 image, because my bandwidth is
> quite limited right now (Vietnam).
>
> --
> Serge Stinckwich
> UCBN & UMI UMMISCO 209 (IRD/UPMC)
> Every DSL ends up being Smalltalk
> http://www.doesnotunderstand.org/
>
>



Reply | Threaded
Open this post in threaded view
|

Re: About Fraction and parentheses

Sven Van Caekenberghe-2
Ah, OK, sorry about the misunderstanding.

> On 20 Dec 2016, at 09:21, Stephane Ducasse <[hidden email]> wrote:
>
> I think that I know that :)
> And this is why I mentioned that if you print 1/3 it prints (1/3) so that we can continue typing + (2/3)
>
> On Mon, Dec 19, 2016 at 11:02 PM, Sven Van Caekenberghe <[hidden email]> wrote:
>
> > On 19 Dec 2016, at 22:00, Stephane Ducasse <[hidden email]> wrote:
> >
> > Hi serge
> >
> > the printing should be normal because like that you are ready to type
> > 1/3 + 2/3 and get 1.
>
> No, not at all:
>
> 1/3 + 2/3
>
>   "(7/9)"
>
> These are all just binary messages evaluated left to right, like this:
>
> ((1/3) + 2)/3
>
>   "(7/9)"
>
> That is why you need the parenthesis in certain contexts.
> Now adding two of them is definitively wrong.
>
> (1/3) + (2/3)
>
>   "1"
>
> (The first parenthesis are not needed, btw).
>
> > Now I do not get why you get ((1/2)) thanks for reporting it.
> >
> > Stef
> >
> > On Mon, Dec 19, 2016 at 9:08 AM, Serge Stinckwich <[hidden email]> wrote:
> > I have one question about Fraction.
> >
> > When I print a fraction like 1/2 in the Playground I obtain (1/2) and
> > when I inspect I obtain ((1/2)). Why do we need all these parentheses
> > ?
> >
> > I didn't try with a current Pharo 6.0 image, because my bandwidth is
> > quite limited right now (Vietnam).
> >
> > --
> > Serge Stinckwich
> > UCBN & UMI UMMISCO 209 (IRD/UPMC)
> > Every DSL ends up being Smalltalk
> > http://www.doesnotunderstand.org/
> >
> >
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: About Fraction and parentheses

stepharong
On Tue, 20 Dec 2016 09:24:57 +0100, Sven Van Caekenberghe <[hidden email]>  
wrote:

> Ah, OK, sorry about the misunderstanding.

you are welcome :)
Now I do not get why there would be ((1/3))
I have to check

>
>> On 20 Dec 2016, at 09:21, Stephane Ducasse <[hidden email]>  
>> wrote:
>>
>> I think that I know that :)
>> And this is why I mentioned that if you print 1/3 it prints (1/3) so  
>> that we can continue typing + (2/3)
>>
>> On Mon, Dec 19, 2016 at 11:02 PM, Sven Van Caekenberghe <[hidden email]>  
>> wrote:
>>
>> > On 19 Dec 2016, at 22:00, Stephane Ducasse <[hidden email]>  
>> wrote:
>> >
>> > Hi serge
>> >
>> > the printing should be normal because like that you are ready to type
>> > 1/3 + 2/3 and get 1.
>>
>> No, not at all:
>>
>> 1/3 + 2/3
>>
>>   "(7/9)"
>>
>> These are all just binary messages evaluated left to right, like this:
>>
>> ((1/3) + 2)/3
>>
>>   "(7/9)"
>>
>> That is why you need the parenthesis in certain contexts.
>> Now adding two of them is definitively wrong.
>>
>> (1/3) + (2/3)
>>
>>   "1"
>>
>> (The first parenthesis are not needed, btw).
>>
>> > Now I do not get why you get ((1/2)) thanks for reporting it.
>> >
>> > Stef
>> >
>> > On Mon, Dec 19, 2016 at 9:08 AM, Serge Stinckwich  
>> <[hidden email]> wrote:
>> > I have one question about Fraction.
>> >
>> > When I print a fraction like 1/2 in the Playground I obtain (1/2) and
>> > when I inspect I obtain ((1/2)). Why do we need all these parentheses
>> > ?
>> >
>> > I didn't try with a current Pharo 6.0 image, because my bandwidth is
>> > quite limited right now (Vietnam).
>> >
>> > --
>> > Serge Stinckwich
>> > UCBN & UMI UMMISCO 209 (IRD/UPMC)
>> > Every DSL ends up being Smalltalk
>> > http://www.doesnotunderstand.org/
>> >
>> >
>>
>>
>>
>
>


--
Using Opera's mail client: http://www.opera.com/mail/