Open github-actions[bot] opened 1 year ago
I have more questions than suggestions for this:
How should it work? Converting a binary to integer? If yes, should this integer be signed or unsigned? What should happen if my binary's size is other than a multiple of 2, let me say, 3 bits, for instance?
The :binary
type in Arturo is actually a Block of bytes. And... every byte is just that a byte, or 8 bits. (In general, you may access an individual bit, but you cannot define anything, a concrete value, as having "3 bits"... everything, structurally has to be a multiple of 8 bits or a byte)
Now, that being said, and given that the underlying values are actually bytes (that is an unsigned 8-bit int: https://nim-lang.org/docs/system.html#byte), what would make sense for <
/>
testing would be to sequentially compare the individual bytes.
So,... with a: [10 11 12 13 14]
and b: [10 20 12 23 23]
, I'd think of sth like:
a < b
And this wouldn't be related to the bytearray sizes at all.
In any case, if you want to have a look into how other languages deal with it, there could be something we are missing 😉
So,... with a: [10 11 12 13 14] and b: [10 20 12 23 23], I'd think of sth like:
- compare the first element of A with the first element of B
- they're equal, so let's move on
- compare the secodn element of A wi th the second element of B
- a[1] < b[1], so I guess this would mean a < b
I'm curious now, should it work with the same process for blocks and inlines?
And this wouldn't be related to the bytearray sizes at all.
Got it! Thanks for the explanation!
In any case, if you want to have a look into how other languages deal with it, there could be something we are missing 😉
All right!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
[VM/values/comparison] add
<
/>
support for Binary values currently,=
is supported but not<
and>
! Preferrably, the implementation should go to values/custom/vbinary and then integrate it here. see also: https://github.com/arturo-lang/arturo/pull/1139https://github.com/arturo-lang/arturo/blob/269a723e23971f7c5ba310f6c3539852a6f016e3/src/vm/values/comparison.nim#L265
a8557c13f4142938288329165fb14d20ee5b121f