#asInteger truncates instead of rounding

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

#asInteger truncates instead of rounding

Richard Sargent
Administrator
As some of you may have noticed, #asInteger truncates. ANSI Smalltalk specifies that it should round. Consequently, we are considering changing this with the other ANSI compatibility changes we are making for the 3.2 release.

I would like to know whether anyone is relying on the the truncation behaviour or would rather we do not change this.


Thanks,
Richard
Reply | Threaded
Open this post in threaded view
|

Re: #asInteger truncates instead of rounding

federico.mennite@lifeware.ch
Hi,
We are also working with VisualWorks who is also truncating.
Of course we'd prefer to have the same behavior in both dialects but we
could also reimplement the new method to the old behavior.
We'd like to ask however if you could make sure that the system classes
aren't  going to rely on it...

Best Regards,
Federico


On 30.01.2014 19:58, Richard Sargent wrote:

> As some of you may have noticed, #asInteger truncates. ANSI Smalltalk
> specifies that it should round. Consequently, we are considering changing
> this with the other ANSI compatibility changes we are making for the 3.2
> release.
>
> I would like to know whether anyone is relying on the the truncation
> behaviour or would rather we do not change this.
>
>
> Thanks,
> Richard
>
>
>
> --
> View this message in context: http://forum.world.st/asInteger-truncates-instead-of-rounding-tp4740457.html
> Sent from the Gemstone/S mailing list archive at Nabble.com.
> _______________________________________________
> GemStone-Smalltalk mailing list
> [hidden email]
> http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk

--
Federico Mennite
Software Engineer
Lifeware SA           Web: http://www.lifeware.ch

_______________________________________________
GemStone-Smalltalk mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: #asInteger truncates instead of rounding

Kevin Szabo-2
In reply to this post by Richard Sargent
My opinion is that this method should not be changed. 

The method #asInteger has truncated forever, and I expect there are many objects and much undocumented legacy code that rely on this.  I looked at my Object Reference from ParcPlace Digitalk (Rev 1.1, 1995) and the documentation for Number>>#asInteger states "Discard any fractional part." so this behaviour is at least 18 years old. 

I did look at Stephane's scanned version of the Blue Book to see if this behaviour existed since the epoch, but the protocol on number was #truncated and #rounded (http://stephane.ducasse.free.fr/FreeBooks/BlueBook/Bluebook.pdf) so #asInteger is younger than 33 years.

Cheers,
Kevin


On Thu, Jan 30, 2014 at 1:58 PM, Richard Sargent <[hidden email]> wrote:
As some of you may have noticed, #asInteger truncates. ANSI Smalltalk
specifies that it should round. Consequently, we are considering changing
this with the other ANSI compatibility changes we are making for the 3.2
release.

I would like to know whether anyone is relying on the the truncation
behaviour or would rather we do not change this.


Thanks,
Richard



--
View this message in context: http://forum.world.st/asInteger-truncates-instead-of-rounding-tp4740457.html
Sent from the Gemstone/S mailing list archive at Nabble.com.
_______________________________________________
GemStone-Smalltalk mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk


_______________________________________________
GemStone-Smalltalk mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: #asInteger truncates instead of rounding

martin_kraft
In reply to this post by Richard Sargent
Hi Richard,

we do rely on VisualWorks answering the same result as GemStone, which is truncating towards zero.

If you could get VisualWorks >= v9.10 aligned with GemStone >= v3.2 and the ANSI standard in some future version I would be happy to support this questionable approach once we upgrade both GS and VW.


Nevertheless, my personal opinion of "asInteger" sent to a number is that it should truncate towards zero.

Other languages do that since many years.


Maybe a reason to revisit the Smalltalk ANSI standard for "asInteger" ... :-)


Cheers,
Martin F.Kraft


From: "Richard Sargent" <[hidden email]>
To: [hidden email]
Sent: Thursday, January 30, 2014 1:58:05 PM
Subject: [GemStone-Smalltalk] #asInteger truncates instead  of rounding

As some of you may have noticed, #asInteger truncates. ANSI Smalltalk
specifies that it should round. Consequently, we are considering changing
this with the other ANSI compatibility changes we are making for the 3.2
release.

I would like to know whether anyone is relying on the the truncation
behaviour or would rather we do not change this.


Thanks,
Richard



--
View this message in context: http://forum.world.st/asInteger-truncates-instead-of-rounding-tp4740457.html
Sent from the Gemstone/S mailing list archive at Nabble.com.
_______________________________________________
GemStone-Smalltalk mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk


_______________________________________________
GemStone-Smalltalk mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: #asInteger truncates instead of rounding

Bruce Badger
Hear hear.  The ANSI standard should not be viewed as inert, but should be a living evolving (but crisply versioned) document.  I'd still love to see an on-gong process revived.

I agree with the argument that changing asInteger would be a bad idea.  Better to remove asInteger from the standard and add in it's place asIntegerRounded and asIntegerTruncated (or similar).  Explicit is always better IMO anyway.

Bruce


On 2 February 2014 16:26, <[hidden email]> wrote:
Hi Richard,

we do rely on VisualWorks answering the same result as GemStone, which is truncating towards zero.

If you could get VisualWorks >= v9.10 aligned with GemStone >= v3.2 and the ANSI standard in some future version I would be happy to support this questionable approach once we upgrade both GS and VW.


Nevertheless, my personal opinion of "asInteger" sent to a number is that it should truncate towards zero.

Other languages do that since many years.


Maybe a reason to revisit the Smalltalk ANSI standard for "asInteger" ... :-)


Cheers,
Martin F.Kraft


From: "Richard Sargent" <[hidden email]>
To: [hidden email]
Sent: Thursday, January 30, 2014 1:58:05 PM
Subject: [GemStone-Smalltalk] #asInteger truncates instead  of rounding


As some of you may have noticed, #asInteger truncates. ANSI Smalltalk
specifies that it should round. Consequently, we are considering changing
this with the other ANSI compatibility changes we are making for the 3.2
release.

I would like to know whether anyone is relying on the the truncation
behaviour or would rather we do not change this.


Thanks,
Richard



--
View this message in context: http://forum.world.st/asInteger-truncates-instead-of-rounding-tp4740457.html
Sent from the Gemstone/S mailing list archive at Nabble.com.
_______________________________________________
GemStone-Smalltalk mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk


_______________________________________________
GemStone-Smalltalk mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk




--
Make the most of your skills - with OpenSkills
http://www.openskills.org/

_______________________________________________
GemStone-Smalltalk mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: #asInteger truncates instead of rounding

Richard Sargent
Administrator
Thank you all for your feedback. It is greatly appreciated.

Bruce, I have to agree that explicit is always best! :-)