0

In Javascript, byte endianness is determined by the underlying hardware. Through DataView, you can assign byte endianness as big or little.

What is the behavior for bit endianness? Will it inherit from hardware as well? Can DataView manipulate bit endianness as well?

I have a bitmask in a UI which may run on machines which are big or little endian.

Will Number(n).toString(2) return the same order regardless of machine hardware or DataView assignment? Will Number(2).toString(2) always return "10"?

nemo
  • 334
  • 1
  • 3
  • 10
  • Bit endianness does not exist. Bits don't have address. – slebetman May 29 '18 at 02:42
  • @slebetman - [I have come across a few examples which describe the order of the bits in similar terms.](https://en.wikipedia.org/wiki/Endianness#Bit_endianness) – nemo May 29 '18 at 03:03
  • That has nothing to do with memory thus it has nothing to do with javascript. Bit endianness only applies when you have to transmit digital data over a wire or radio signal because both a single wire and radios can only transmit one bit at a time - thus you are forced to decide which bit to send first – slebetman May 29 '18 at 03:17
  • A question asking "what is the bit endianness on Wifi" or "what is the bit endianness in USB" makes sense. A question asking "what is the bit endianness in javascript" or "what is the bit endianness on intel CPU" makes no sense – slebetman May 29 '18 at 03:18
  • "one bit at a time" - I'm of course overly simplifying here but the point still stands – slebetman May 29 '18 at 03:20
  • @slebetman Ok, based on this [first answer](https://stackoverflow.com/questions/7869752/javascript-typed-arrays-and-endianness) I had the impression that this _is_ something that should be considered as hardware can influence it. I'm just trying to verify that `Number(2).toString(2)` always return `"10"` regardless of hardware. – nemo May 29 '18 at 03:27
  • 1
    Yes. That's always the case – slebetman May 29 '18 at 03:33
  • https://stackoverflow.com/questions/7869752/javascript-typed-arrays-and-endianness – Slai May 29 '18 at 04:11

1 Answers1

0

Based on a comment by @slebetman, Number(2).toString(2) will always return "10".

nemo
  • 334
  • 1
  • 3
  • 10