Skip to content
Advertisement

Tag: binary

Only half of array gets raised to power

I wanted to create binary to decimal calculator. When i tried to console log both of arrays (binary is array of 0’s and 1’s, binarypos is array of numbers that are powers of 2. Screenshot Then i created simpler version, made in console so chance of making a mistake lowered to zero. But the bug appears again! I want it

Number sign issue when porting JavaScript code to Lua

I’ve been trying to port some JavaScript code to Lua. The code encodes and decodes data to and from a binary stream. I am having an issue when trying to port some JavaScript code that can contain signed integers. The JavaScript code looks as such: This code is based on code found in this library: https://github.com/hathora/bin-serde-ts/blob/develop/index.ts I’ve added simplified versions

Is there any way to see a number in it’s 64 bit float IEEE754 representation

Javascript stores all numbers as double-precision 64-bit format IEEE 754 values according to the spec: The Number type has exactly 18437736874454810627 (that is, 264−253+3) values, representing the double-precision 64-bit format IEEE 754 values as specified in the IEEE Standard for Binary Floating-Point Arithmetic Is there any way to see the number in this form in Javascript? Answer Based on @Pointy’s

Advertisement