UNPKG

double-double

Version:

Pure double-double precision functions *with strict error bounds*.

1 lines 6.75 kB
(window.webpackJsonp=window.webpackJsonp||[]).push([[33],{170:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return i})),n.d(t,"metadata",(function(){return l})),n.d(t,"rightToc",(function(){return o})),n.d(t,"default",(function(){return p}));var r=n(2),a=n(9),b=(n(0),n(207)),i={id:"_double_representation_is_bit_aligned_",title:"isBitAligned",sidebar_label:"isBitAligned"},l={id:"modules/_double_representation_is_bit_aligned_",isDocsHomePage:!1,title:"isBitAligned",description:"isBitAligned(a number, gridSpacingExponent boolean",source:"@site/docs\\modules\\_double_representation_is_bit_aligned_.md",permalink:"/double-double/docs/modules/_double_representation_is_bit_aligned_",sidebar_label:"isBitAligned",sidebar:"sidebar",previous:{title:"getLowestSetBit / getHighestSetBit",permalink:"/double-double/docs/modules/_double_representation_get_max_set_bit_"},next:{title:"lsbExponent",permalink:"/double-double/docs/modules/_double_representation_lsb_exponent_"}},o=[],c={rightToc:o};function p(e){var t=e.components,n=Object(a.a)(e,["components"]);return Object(b.b)("wrapper",Object(r.a)({},c,n,{components:t,mdxType:"MDXLayout"}),Object(b.b)("p",null,Object(b.b)("strong",{parentName:"p"},"isBitAligned"),"(",Object(b.b)("inlineCode",{parentName:"p"},"a"),": number, ",Object(b.b)("inlineCode",{parentName:"p"},"maxBitLength"),": number, ",Object(b.b)("inlineCode",{parentName:"p"},"gridSpacingExponent"),": number): ",Object(b.b)("em",{parentName:"p"},"boolean")),Object(b.b)("p",null,Object(b.b)("em",{parentName:"p"},"Defined in ",Object(b.b)("a",Object(r.a)({parentName:"em"},{href:"https://github.com/FlorisSteenkamp/double-double/blob/d35ae52/src/double-representation/is-bit-aligned.ts#L33"}),"double-representation/is-bit-aligned.ts:33"))),Object(b.b)("p",null,"Returns true if the given number is bit-aligned in the sense that its a\nmultiple of a given power of 2, say e, and such that the number, say a,\nconforms to: a/2^e < 2^(l-e), where l is the max allowed bit length.\nThis essentially means the numbers act somewhat like fixed-point numbers\nwhich can drastically speed up some geometric algorithms and also reduce\ntheir complexity."),Object(b.b)("p",null,"Visually:\nThese numbers (a,b and c) are grid aligned with e === 3 and max\nbitlength === 6:",Object(b.b)("br",{parentName:"p"}),"\n","a -> 00|101100|000",Object(b.b)("br",{parentName:"p"}),"\n","b -> 00|000100|000",Object(b.b)("br",{parentName:"p"}),"\n","c -> 00|110111|000",Object(b.b)("br",{parentName:"p"}),"\n","These are not",Object(b.b)("br",{parentName:"p"}),"\n","a -> 01|101100|000",Object(b.b)("br",{parentName:"p"}),"\n","b -> 00|000100|000",Object(b.b)("br",{parentName:"p"}),"\n","These are not",Object(b.b)("br",{parentName:"p"}),"\n","a -> 00|101100|000",Object(b.b)("br",{parentName:"p"}),"\n","b -> 00|000100|100",Object(b.b)("br",{parentName:"p"}),"\n","These are not",Object(b.b)("br",{parentName:"p"}),"\n","a -> 00|101100|100",Object(b.b)("br",{parentName:"p"}),"\n","b -> 00|000100|100 "),Object(b.b)("p",null,Object(b.b)("strong",{parentName:"p"},"Parameters:")),Object(b.b)("table",null,Object(b.b)("thead",{parentName:"table"},Object(b.b)("tr",{parentName:"thead"},Object(b.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Name"),Object(b.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Type"),Object(b.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Description"))),Object(b.b)("tbody",{parentName:"table"},Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(r.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"a")),Object(b.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"number"),Object(b.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"-")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(r.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"maxBitLength")),Object(b.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"number"),Object(b.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"The max allowed bitlength")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(r.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"gridSpacingExponent")),Object(b.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"number"),Object(b.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"The grid spacing === 1^gridSpacingExponent")))),Object(b.b)("p",null,Object(b.b)("strong",{parentName:"p"},"Returns:")," ",Object(b.b)("em",{parentName:"p"},"boolean")))}p.isMDXComponent=!0},207:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return d}));var r=n(0),a=n.n(r);function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){b(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},b=Object.keys(e);for(r=0;r<b.length;r++)n=b[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(e);for(r=0;r<b.length;r++)n=b[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var c=a.a.createContext({}),p=function(e){var t=a.a.useContext(c),n=t;return e&&(n="function"==typeof e?e(t):l(l({},t),e)),n},u=function(e){var t=p(e.components);return a.a.createElement(c.Provider,{value:t},e.children)},m={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},s=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,b=e.originalType,i=e.parentName,c=o(e,["components","mdxType","originalType","parentName"]),u=p(n),s=r,d=u["".concat(i,".").concat(s)]||u[s]||m[s]||b;return n?a.a.createElement(d,l(l({ref:t},c),{},{components:n})):a.a.createElement(d,l({ref:t},c))}));function d(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var b=n.length,i=new Array(b);i[0]=s;var l={};for(var o in t)hasOwnProperty.call(t,o)&&(l[o]=t[o]);l.originalType=e,l.mdxType="string"==typeof e?e:r,i[1]=l;for(var c=2;c<b;c++)i[c]=n[c];return a.a.createElement.apply(null,i)}return a.a.createElement.apply(null,n)}s.displayName="MDXCreateElement"}}]);