Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View moorthy-g's full-sized avatar

Moorthy moorthy-g

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<script>
const srcAssigner = () => {
const myframe = document.getElementById('myframe');
myframe.src = 'https://w3.org/about';
//Merge Low 30bits and other high bits
//Reverse of https://gist.github.com/moorthy-g/bb3716303384365bce7b98b67af14fd1
function mergeBits30(splitBits) {
let [highBits, lowBits] = splitBits;
return (highBits & 0x3fffff) * 0x40000000 + (lowBits & 0x3fffffff);
}
//Javascript stores integer values in upto 52 bits binary
//But, it performs bitwise operations on 32 bits only
//This gist splits 30 lowbits & the other high bits(total of 52 bits)
//helpful for bitwise operations
function bitSplitAt30(n) {
if(n > 0x3fffffff) {
const lowBits = n & 0x3fffffff;
const highBits = (n-lowBits)/0x40000000;
return [highBits, lowBits];
}
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Moorthy <moorthyrweb@gmail.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE