Skip to main content
13 votes
Accepted

What are the disadvantages of this far-fetched idea: All integers can be treated as boolean arrays?

I wouldn't store them as arrays, but you can certainly implement such a syntax efficiently. If you translate x[0] to x & 1 ...
ruarq's user avatar
  • 146
8 votes

What are the disadvantages of this far-fetched idea: All integers can be treated as boolean arrays?

It would encourage inefficient code 90% of the time when you're doing individual bit lookups on an int, you're doing something "wrong". E.g., this would encourage those who don't feel ...
Rydwolf Programs's user avatar
6 votes

What are the disadvantages of this far-fetched idea: All integers can be treated as boolean arrays?

Strictly speaking, an "array" is a specific kind of data structure where elements are stored at contiguous, equally-spaced memory addresses. The smallest addressable unit of memory is ...
kaya3's user avatar
  • 19.7k
5 votes

What are the disadvantages of this far-fetched idea: All integers can be treated as boolean arrays?

It privileges one form of bit access over others Accessing a word as a bit vector can be useful in some circumstances, but even more useful is the ability to pack and unpack general bit fields. Things ...
Pseudonym's user avatar
  • 4,716
5 votes
Accepted

What should be the precedence of the bitwise operators relative to each others?

The precedence should be the same as it is in C, for several reasons. C got it right C got the relative precedences for these operators right*, so there's nothing to fix by changing it: ...
kaya3's user avatar
  • 19.7k
3 votes

Should bitwise operations have dedicated operators?

Many modern languages support built-in operator overloading (e.g. Python and JavaScript use + for both numeric addition and string concatenation), and often user-...
Barmar's user avatar
  • 1,901
2 votes

What should be the precedence of the bitwise operators relative to each others?

If you want to minimize the need for parentheses Let's typical use case of bitshift/masking operations. Bit arrays Suppose that you have a bit array class, allowing an integer (or array of integers) ...
dan04's user avatar
  • 1,949
2 votes

What are the disadvantages of this far-fetched idea: All integers can be treated as boolean arrays?

As integers (certainly positive integers) are representable in base 2 as binary numbers, and a binary internal representation is also most common, integers arguably are bit (Boolean) arrays. So the ...
LHP's user avatar
  • 156
2 votes

What are the disadvantages of this far-fetched idea: All integers can be treated as boolean arrays?

I do not know of any languages that support this idea Let's fix that :-) Vyxal is a code golf language which allows indexing into an integer as if it was a collection of digits: ...
Adám's user avatar
  • 3,156

Only top scored, non community-wiki answers of a minimum length are eligible