Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1769.mcz ==================== Summary ==================== Name: Morphic-mt.1769 Author: mt Time: 6 May 2021, 7:05:24.828981 pm UUID: 8109f744-f1f3-7048-8646-fed21a8e23d4 Ancestors: Morphic-ct.1768 Fixes minor glitch in objext explorers on integers. This makes me wonder ... what are the expectations for negative integers here? =============== Diff against Morphic-ct.1768 =============== Item was changed: ----- Method: Integer>>explorerContents (in category '*Morphic-Explorer') ----- explorerContents ^#( ('hexadecimal' 16 2) ('octal' 8 3) ('binary' 2 4)) collect: [ :each | | label group | group := each third. + label := self abs printStringBase: each second. - label := self printStringBase: each second. label := label padded: #left to: (label size roundUpTo: group) with: $0. label := String streamContents: [:s | + self negative ifTrue: [s nextPutAll: '- ']. (1 to: label size by: group) do: [:index | 1 to: group do: [:gIndex | s nextPut: (label at: index + gIndex - 1)]] separatedBy: [s space]]. ObjectExplorerWrapper with: label name: each first translated model: self ]! |
Nice catch! :-)
For anyone else wondering about this glitch: Before:
After:
IMO our printing protocol on Number should have a padded argument similar to the (post-comma) decimal places.
Apart from that, I would have expected '-02' instead of '- 02'. :-)
Best,
Christoph
Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Donnerstag, 6. Mai 2021 19:05:29 An: [hidden email]; [hidden email] Betreff: [squeak-dev] The Trunk: Morphic-mt.1769.mcz Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1769.mcz ==================== Summary ==================== Name: Morphic-mt.1769 Author: mt Time: 6 May 2021, 7:05:24.828981 pm UUID: 8109f744-f1f3-7048-8646-fed21a8e23d4 Ancestors: Morphic-ct.1768 Fixes minor glitch in objext explorers on integers. This makes me wonder ... what are the expectations for negative integers here? =============== Diff against Morphic-ct.1768 =============== Item was changed: ----- Method: Integer>>explorerContents (in category '*Morphic-Explorer') ----- explorerContents ^#( ('hexadecimal' 16 2) ('octal' 8 3) ('binary' 2 4)) collect: [ :each | | label group | group := each third. + label := self abs printStringBase: each second. - label := self printStringBase: each second. label := label padded: #left to: (label size roundUpTo: group) with: $0. label := String streamContents: [:s | + self negative ifTrue: [s nextPutAll: '- ']. (1 to: label size by: group) do: [:index | 1 to: group do: [:gIndex | s nextPut: (label at: index + gIndex - 1)]] separatedBy: [s space]]. ObjectExplorerWrapper with: label name: each first translated model: self ]!
Carpe Squeak!
|
> Apart from that, I would have expected '-02' instead of '- 02'. :-) And I would have expected a 2's complement, right? Or even drop this representation for negative numbers altogether? Best, Marcel
|
> And I would have expected a 2's complement, right?
Ah, now I see. :-) But this would not really match the actual object layout of integers in Squeak which can have arbitrary sizes ...
In my opinion, we should just leave it as is (just maybe without the space), I don't really like such artificial limitations. :-)
Best, Christoph Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Montag, 17. Mai 2021 12:52:23 An: squeak-dev Betreff: Re: [squeak-dev] The Trunk: Morphic-mt.1769.mcz
> Apart from that, I would have expected '-02' instead of '- 02'. :-)
And I would have expected a 2's complement, right? Or even drop this representation for negative numbers altogether?
Best,
Marcel
Carpe Squeak!
|
> But this would not really match the actual object layout of integers in Squeak which can have arbitrary sizes ... So, the binary representation does not make sense, right? And neither does the HEX or OCT. :-) Best, Marcel
|
> > But this would not really match the actual object layout of integers in Squeak which can have arbitrary sizes ... >
> So, the binary representation does not make sense, right? And neither does the HEX or OCT. :-)
Why do you think so? The object layout of Squeak Integer is not something like "list of decimal digits". The decimal representation is just one of many equivalent representations. On the other hand, any complement semantic adds a completely new concept
because it neglects the infinite size of integers.
Best,
Christoph
Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Montag, 17. Mai 2021 13:08:47 An: squeak-dev Betreff: Re: [squeak-dev] The Trunk: Morphic-mt.1769.mcz
> But this would not really match the actual object layout of integers in Squeak which can have arbitrary sizes ...
So, the binary representation does not make sense, right? And neither does the HEX or OCT. :-)
Best,
Marcel
Carpe Squeak!
|
> The decimal representation is just one of many equivalent representations. The problem being that the basic (machine) representation is not clear. I think its 2's complement. HEX and OCT -- I suppose -- are very close to the machine representation. That's not an issue for positive numbers. :-) Best, Marcel
|
Hi all, Virtual Machine implementation is a detail. SmallInteger are two complement, while LargeNegativeInteger are sign magnitude (with sign encoded in the class). From bit perspective (bitAnd: bitOr: bitAt: etc...), all Integer behave as two complement with an infinite sequence of 1 for negative, and infinite sequence of 0 for positive. We could express this in inspectors with a bits field and a leading ... 00000000 or ... 11111111 digit (yes digits are 1 byte long currently). Le lun. 17 mai 2021 à 15:35, Marcel Taeumel <[hidden email]> a écrit :
pastedImage.png (10K) Download Attachment pastedImage.png (10K) Download Attachment pastedImage.png (10K) Download Attachment |
Hi Nicolas, > We could express this in inspectors with a bits field and a leading ... 00000000 or ... 11111111 digit (yes digits are 1 byte long currently). You mean like this? DEC -2 HEX -02 OCT -002 BIN -0010 BIT 1111 1111 1111 1110 ? Best, Marcel
|
|
Hi Marcel, yes, maybe with some ellipsis ahead "..." to denote the fact that it's infinite... Le mar. 18 mai 2021 à 16:13, Marcel Taeumel <[hidden email]> a écrit :
|
Free forum by Nabble | Edit this page |