
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Converts int bits to a float32 and back. Useful for packing and unpacking RGBA bits into a single float (e.g. for interleaving float data in WebGL). This technique only works on browsers that implement typed arrays correctly.
var pack = require('int-bits')
//gets a single ABGR representation of 4 color bytes
var bits = (a << 24 | b << 16 | g << 8 | r)
//pack to a float value for use with a Float32Array
var rgba = pack(bits & 0xfeffffff)
You can also unpack a float32 to int bits. Since there is some precision loss in the high bits, it's best to bias the alpha channel toward 0 and 255.
var unpack = require('int-bits').unpack
var bits = unpack(rgba)
var A = (bits & 0xff000000) >>> 24
var B = (bits & 0x00ff0000) >>> 16
var G = (bits & 0x0000ff00) >>> 8
var R = (bits & 0x000000ff)
//fix precision loss with high bits
A = Math.floor(A*(255/254))
f = require('int-bits')(bits)f = require('int-bits').pack(bits)Converts the int bits into a float32 value using typed arrays.
i = require('int-bits').unpack(f)Converts the float32 value back to int bits using typed arrays.
MIT, see LICENSE.md for details.
FAQs
converts int bits to float and back
We found that int-bits demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.