REBOL 3.0

Comments on: AND truncation of series

Carl Sassenrath, CTO
REBOL Technologies
3-Jul-2009 5:15 GMT

Article #0216
Main page || Index || Prior Article [0215] || Next Article [0217] || 6 Comments || Send feedback

Sometimes I just need to ask...

Do you see the value in the truncation of this operation:

>> #{010203} and #{0202}
== #{0002}

(Note that the result is the length of the shorter argument.)

However:

>> #{010203} or #{0202}
== #{030203}

leaves it full length.

There may have been some logical reason in the past, but if their was, I don't see it in the docs. So, unless someone objects, AND will be modified to produce the same length as OR.

This is Curecode bug #1013.

6 Comments

Comments:

Brian Hawley
3-Jul-2009 2:33:46
One possibility wold be to pretend that the short binary was 00-padded to the length of the longer one and then AND it:
>> #{010203} and #{0202}
== #{000200}
>> (#{010203} and #{0202}) = (#{010203} and #{020200})
== true

This would be consistent with the behavior of OR:

>> #{010203} or #{0202}
== #{030203}
>> (#{010203} or #{0202}) = (#{010203} or #{020200})
== true

FF-padding would not be consistent with OR:

>> #{010203} and #{0202}
== #{000203}
>> (#{010203} and #{0202}) = (#{010203} and #{0202FF})
== true
Pijoter
3-Jul-2009 3:20:22
Short binary will be 00-padded from left or right side?

For now (view 2.6):

>> to-integer (#{FFFF} and #{00});== 255
>> (to-integer #{FFFF}) and (to-integer #{00});== 0

Sunanda
3-Jul-2009 3:23:46
zero padding would also be consistent with existing (R2 and
    1.2.3 and 1.2.3.4.5
    == 1.2.3.0.0>
Gregg Irwin
3-Jul-2009 8:55:31
Zero padding makes sense to me.
Brian Hawley
3-Jul-2009 16:10:59
Piotr: "Short binary will be 00-padded from left or right side?"

Padded on the right side.

Carl Sassenrath
6-Jul-2009 13:20:50
This change has been made.

Post a Comment:

You can post a comment here. Keep it on-topic.

Name:

Blog id:

R3-0216


Comment:


 Note: HTML tags allowed for: b i u li ol ul font span div a p br pre tt blockquote
 
 

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

REBOL 3.0
Updated 22-Sep-2017 - Edit - Copyright REBOL Technologies - REBOL.net