[{"data":1,"prerenderedAt":815},["ShallowReactive",2],{"navigation_docs":3,"-encodings-integer":140,"-encodings-integer-surround":810},[4,52],{"title":5,"path":6,"stem":7,"children":8,"icon":51},"Guide","\u002Fguide","1.guide\u002F01.index",[9,11,15,19,23,27,31,35,39,43,47],{"title":10,"path":6,"stem":7},"Getting Started",{"title":12,"path":13,"stem":14},"Encoding and Decoding","\u002Fguide\u002Fencoding","1.guide\u002F02.encoding",{"title":16,"path":17,"stem":18},"Checksums","\u002Fguide\u002Fchecksums","1.guide\u002F03.checksums",{"title":20,"path":21,"stem":22},"Identify","\u002Fguide\u002Fidentify","1.guide\u002F04.identify",{"title":24,"path":25,"stem":26},"CLI","\u002Fguide\u002Fcli","1.guide\u002F05.cli",{"title":28,"path":29,"stem":30},"Agents","\u002Fguide\u002Fagents","1.guide\u002F06.agents",{"title":32,"path":33,"stem":34},"Code pages","\u002Fguide\u002Fcode-pages","1.guide\u002F07.code-pages",{"title":36,"path":37,"stem":38},"RLP","\u002Fguide\u002Frlp","1.guide\u002F08.rlp",{"title":40,"path":41,"stem":42},"OpenPGP armor","\u002Fguide\u002Farmor","1.guide\u002F09.armor",{"title":44,"path":45,"stem":46},"Custom Encodings","\u002Fguide\u002Fcustom","1.guide\u002F10.custom",{"title":48,"path":49,"stem":50},"Playground","\u002Fguide\u002Fplayground","1.guide\u002F11.playground","i-lucide-book-open",{"title":53,"path":54,"stem":55,"children":56,"icon":139},"Encodings","\u002Fencodings","2.encodings\u002F00.index",[57,59,63,67,71,75,79,83,87,91,95,99,103,107,111,115,119,123,127,131,135],{"title":58,"path":54,"stem":55},"Every encoding",{"title":60,"path":61,"stem":62},"Binary","\u002Fencodings\u002Fbinary","2.encodings\u002F01.binary",{"title":64,"path":65,"stem":66},"Octal","\u002Fencodings\u002Foctal","2.encodings\u002F02.octal",{"title":68,"path":69,"stem":70},"Decimal","\u002Fencodings\u002Fdecimal","2.encodings\u002F03.decimal",{"title":72,"path":73,"stem":74},"Integer","\u002Fencodings\u002Finteger","2.encodings\u002F03.integer",{"title":76,"path":77,"stem":78},"Hex","\u002Fencodings\u002Fhex","2.encodings\u002F04.hex",{"title":80,"path":81,"stem":82},"Base32","\u002Fencodings\u002Fbase32","2.encodings\u002F05.base32",{"title":84,"path":85,"stem":86},"Base45","\u002Fencodings\u002Fbase45","2.encodings\u002F09.base45",{"title":88,"path":89,"stem":90},"Base58","\u002Fencodings\u002Fbase58","2.encodings\u002F10.base58",{"title":92,"path":93,"stem":94},"Base64","\u002Fencodings\u002Fbase64","2.encodings\u002F14.base64",{"title":96,"path":97,"stem":98},"Base85","\u002Fencodings\u002Fbase85","2.encodings\u002F18.base85",{"title":100,"path":101,"stem":102},"basE91","\u002Fencodings\u002Fbase91","2.encodings\u002F19.base91",{"title":104,"path":105,"stem":106},"Base256","\u002Fencodings\u002Fbase256","2.encodings\u002F20.base256",{"title":108,"path":109,"stem":110},"Bech32","\u002Fencodings\u002Fbech32","2.encodings\u002F21.bech32",{"title":112,"path":113,"stem":114},"uuencode","\u002Fencodings\u002Fuuencode","2.encodings\u002F22.uuencode",{"title":116,"path":117,"stem":118},"Quoted-Printable","\u002Fencodings\u002Fquoted-printable","2.encodings\u002F23.quoted-printable",{"title":120,"path":121,"stem":122},"HTML","\u002Fencodings\u002Fhtml","2.encodings\u002F24.html",{"title":124,"path":125,"stem":126},"ITA2","\u002Fencodings\u002Fita2","2.encodings\u002F25.ita2",{"title":128,"path":129,"stem":130},"Prefix codes","\u002Fencodings\u002Fprefix","2.encodings\u002F26.prefix",{"title":132,"path":133,"stem":134},"Chess squares","\u002Fencodings\u002Fsquare","2.encodings\u002F27.square",{"title":136,"path":137,"stem":138},"FEN","\u002Fencodings\u002Ffen","2.encodings\u002F28.fen","i-lucide-library",{"id":141,"title":72,"body":142,"description":804,"extension":805,"links":806,"meta":807,"navigation":549,"path":73,"seo":808,"stem":74,"__hash__":809},"docs\u002F2.encodings\u002F03.integer.md",{"type":143,"value":144,"toc":798},"minimark",[145,149,161,258,263,277,318,328,357,360,364,367,415,422,465,469,475,517,520,628,634,644,648,669,708,714,748,771,794],[146,147],"encoding-facts",{"name":148},"integer",[150,151,152,153,156,157,160],"p",{},"The whole text is one number. ",[154,155,148],"code",{}," turns it into big-endian bytes and back. No BigInt loop needed. ",[154,158,159],{},"decimal"," gives each byte its own number instead.",[162,163,168],"pre",{"className":164,"code":165,"language":166,"meta":167,"style":167},"language-ts shiki shiki-themes encodings encodings encodings","encode(\"decimal\", \"Hi\");                   \u002F\u002F \"72 105\"\nencode(\"integer\", \"Hi\");                   \u002F\u002F \"18537\"\nencode(\"integer\", \"Hello\");                \u002F\u002F \"310939249775\"\nencode(\"integer\", \"Hello\", { radix: 16 }); \u002F\u002F \"48656c6c6f\"\n","ts","",[154,169,170,200,219,239],{"__ignoreMap":167},[171,172,175,179,183,187,190,193,196],"span",{"class":173,"line":174},"line",1,[171,176,178],{"class":177},"sK71F","encode",[171,180,182],{"class":181},"s38Sx","(",[171,184,186],{"class":185},"shU9J","\"decimal\"",[171,188,189],{"class":181},", ",[171,191,192],{"class":185},"\"Hi\"",[171,194,195],{"class":181},");                   ",[171,197,199],{"class":198},"scIB-","\u002F\u002F \"72 105\"\n",[171,201,203,205,207,210,212,214,216],{"class":173,"line":202},2,[171,204,178],{"class":177},[171,206,182],{"class":181},[171,208,209],{"class":185},"\"integer\"",[171,211,189],{"class":181},[171,213,192],{"class":185},[171,215,195],{"class":181},[171,217,218],{"class":198},"\u002F\u002F \"18537\"\n",[171,220,222,224,226,228,230,233,236],{"class":173,"line":221},3,[171,223,178],{"class":177},[171,225,182],{"class":181},[171,227,209],{"class":185},[171,229,189],{"class":181},[171,231,232],{"class":185},"\"Hello\"",[171,234,235],{"class":181},");                ",[171,237,238],{"class":198},"\u002F\u002F \"310939249775\"\n",[171,240,242,244,246,248,250,252,255],{"class":173,"line":241},4,[171,243,178],{"class":177},[171,245,182],{"class":181},[171,247,209],{"class":185},[171,249,189],{"class":181},[171,251,232],{"class":185},[171,253,254],{"class":181},", { radix: 16 }); ",[171,256,257],{"class":198},"\u002F\u002F \"48656c6c6f\"\n",[259,260,262],"h2",{"id":261},"choosing-a-base-or-custom-digits","Choosing a base or custom digits",[150,264,265,268,269,272,273,276],{},[154,266,267],{},"radix"," runs from 2 to 36 and defaults to 10. Its digits are ",[154,270,271],{},"0-9"," followed by ",[154,274,275],{},"a-z",". Decoding accepts either case.",[162,278,280],{"className":164,"code":279,"language":166,"meta":167,"style":167},"encode(\"integer\", \"Hello\", { radix: 36 }); \u002F\u002F \"3yud78mn\"\nencode(\"integer\", \"Hello\", { radix: 9 });  \u002F\u002F \"1081526044305\"\n",[154,281,282,300],{"__ignoreMap":167},[171,283,284,286,288,290,292,294,297],{"class":173,"line":174},[171,285,178],{"class":177},[171,287,182],{"class":181},[171,289,209],{"class":185},[171,291,189],{"class":181},[171,293,232],{"class":185},[171,295,296],{"class":181},", { radix: 36 }); ",[171,298,299],{"class":198},"\u002F\u002F \"3yud78mn\"\n",[171,301,302,304,306,308,310,312,315],{"class":173,"line":202},[171,303,178],{"class":177},[171,305,182],{"class":181},[171,307,209],{"class":185},[171,309,189],{"class":181},[171,311,232],{"class":185},[171,313,314],{"class":181},", { radix: 9 });  ",[171,316,317],{"class":198},"\u002F\u002F \"1081526044305\"\n",[150,319,320,321,324,325,327],{},"Want base 62 or emoji digits? Use ",[154,322,323],{},"digits"," instead of ",[154,326,267],{},". Put one symbol per digit, lowest first. Case counts in a custom set.",[162,329,331],{"className":164,"code":330,"language":166,"meta":167,"style":167},"encode(\"integer\", \"Hi\", { digits: \"🌑🌒🌓🌔\" }); \u002F\u002F \"🌒🌑🌓🌑🌒🌓🌓🌒\"\n",[154,332,333],{"__ignoreMap":167},[171,334,335,337,339,341,343,345,348,351,354],{"class":173,"line":174},[171,336,178],{"class":177},[171,338,182],{"class":181},[171,340,209],{"class":185},[171,342,189],{"class":181},[171,344,192],{"class":185},[171,346,347],{"class":181},", { digits: ",[171,349,350],{"class":185},"\"🌑🌒🌓🌔\"",[171,352,353],{"class":181}," }); ",[171,355,356],{"class":198},"\u002F\u002F \"🌒🌑🌓🌑🌒🌓🌓🌒\"\n",[150,358,359],{},"Decoding skips ASCII whitespace. Wrap a big ugly number over lines. It's still one number.",[259,361,363],{"id":362},"why-do-leading-zero-bytes-vanish","Why do leading zero bytes vanish?",[150,365,366],{},"A number has no digits for leading zero bytes. They're lost when you encode.",[162,368,370],{"className":164,"code":369,"language":166,"meta":167,"style":167},"encode(\"integer\", new Uint8Array([0, 1, 255])); \u002F\u002F \"511\"\ndecode(\"integer\", \"511\").bytes;                  \u002F\u002F [1, 255]\n",[154,371,372,395],{"__ignoreMap":167},[171,373,374,376,378,380,382,386,389,392],{"class":173,"line":174},[171,375,178],{"class":177},[171,377,182],{"class":181},[171,379,209],{"class":185},[171,381,189],{"class":181},[171,383,385],{"class":384},"skH_V","new",[171,387,388],{"class":177}," Uint8Array",[171,390,391],{"class":181},"([0, 1, 255])); ",[171,393,394],{"class":198},"\u002F\u002F \"511\"\n",[171,396,397,400,402,404,406,409,412],{"class":173,"line":202},[171,398,399],{"class":177},"decode",[171,401,182],{"class":181},[171,403,209],{"class":185},[171,405,189],{"class":181},[171,407,408],{"class":185},"\"511\"",[171,410,411],{"class":181},").bytes;                  ",[171,413,414],{"class":198},"\u002F\u002F [1, 255]\n",[150,416,417,418,421],{},"That's a bad surprise if you need the original width. Set ",[154,419,420],{},"width"," when decoding to restore leading zero bytes. A number that needs more bytes is refused.",[162,423,425],{"className":164,"code":424,"language":166,"meta":167,"style":167},"decode(\"integer\", \"255\", { width: 4 }).bytes; \u002F\u002F [0, 0, 0, 255]\ndecode(\"integer\", \"256\", { width: 1 });       \u002F\u002F throws: integer: the number takes 2 bytes, over width 1\n",[154,426,427,446],{"__ignoreMap":167},[171,428,429,431,433,435,437,440,443],{"class":173,"line":174},[171,430,399],{"class":177},[171,432,182],{"class":181},[171,434,209],{"class":185},[171,436,189],{"class":181},[171,438,439],{"class":185},"\"255\"",[171,441,442],{"class":181},", { width: 4 }).bytes; ",[171,444,445],{"class":198},"\u002F\u002F [0, 0, 0, 255]\n",[171,447,448,450,452,454,456,459,462],{"class":173,"line":202},[171,449,399],{"class":177},[171,451,182],{"class":181},[171,453,209],{"class":185},[171,455,189],{"class":181},[171,457,458],{"class":185},"\"256\"",[171,460,461],{"class":181},", { width: 1 });       ",[171,463,464],{"class":198},"\u002F\u002F throws: integer: the number takes 2 bytes, over width 1\n",[259,466,468],{"id":467},"bijective-numerals-and-spreadsheet-columns","Bijective numerals and spreadsheet columns",[150,470,471,474],{},[154,472,473],{},"bijective: true"," removes the zero digit. The first symbol means 1. With default digits, bijective bases go up to 35.",[162,476,478],{"className":164,"code":477,"language":166,"meta":167,"style":167},"encode(\"integer\", \"Hello\", { radix: 9, bijective: true }); \u002F\u002F \"981525944295\"\ndecode(\"integer\", \"10\", { bijective: true });              \u002F\u002F throws: integer: \"0\" (U+0030) is not a digit in bijective base 10\n",[154,479,480,498],{"__ignoreMap":167},[171,481,482,484,486,488,490,492,495],{"class":173,"line":174},[171,483,178],{"class":177},[171,485,182],{"class":181},[171,487,209],{"class":185},[171,489,189],{"class":181},[171,491,232],{"class":185},[171,493,494],{"class":181},", { radix: 9, bijective: true }); ",[171,496,497],{"class":198},"\u002F\u002F \"981525944295\"\n",[171,499,500,502,504,506,508,511,514],{"class":173,"line":202},[171,501,399],{"class":177},[171,503,182],{"class":181},[171,505,209],{"class":185},[171,507,189],{"class":181},[171,509,510],{"class":185},"\"10\"",[171,512,513],{"class":181},", { bijective: true });              ",[171,515,516],{"class":198},"\u002F\u002F throws: integer: \"0\" (U+0030) is not a digit in bijective base 10\n",[150,518,519],{},"A spreadsheet column is a number in disguise. Use uppercase letters as digits and turn on bijective mode.",[162,521,523],{"className":164,"code":522,"language":166,"meta":167,"style":167},"const columns = { digits: \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\", bijective: true };\n\ndecode(\"integer\", \"A\", columns).bytes;    \u002F\u002F [1]\ndecode(\"integer\", \"Z\", columns).bytes;    \u002F\u002F [26]\ndecode(\"integer\", \"AA\", columns).bytes;   \u002F\u002F [27]\ndecode(\"integer\", \"XFD\", columns).bytes;  \u002F\u002F [64, 0], so 16384\n",[154,524,525,545,551,570,588,608],{"__ignoreMap":167},[171,526,527,530,533,536,539,542],{"class":173,"line":174},[171,528,529],{"class":384},"const",[171,531,532],{"class":181}," columns ",[171,534,535],{"class":384},"=",[171,537,538],{"class":181}," { digits: ",[171,540,541],{"class":185},"\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"",[171,543,544],{"class":181},", bijective: true };\n",[171,546,547],{"class":173,"line":202},[171,548,550],{"emptyLinePlaceholder":549},true,"\n",[171,552,553,555,557,559,561,564,567],{"class":173,"line":221},[171,554,399],{"class":177},[171,556,182],{"class":181},[171,558,209],{"class":185},[171,560,189],{"class":181},[171,562,563],{"class":185},"\"A\"",[171,565,566],{"class":181},", columns).bytes;    ",[171,568,569],{"class":198},"\u002F\u002F [1]\n",[171,571,572,574,576,578,580,583,585],{"class":173,"line":241},[171,573,399],{"class":177},[171,575,182],{"class":181},[171,577,209],{"class":185},[171,579,189],{"class":181},[171,581,582],{"class":185},"\"Z\"",[171,584,566],{"class":181},[171,586,587],{"class":198},"\u002F\u002F [26]\n",[171,589,591,593,595,597,599,602,605],{"class":173,"line":590},5,[171,592,399],{"class":177},[171,594,182],{"class":181},[171,596,209],{"class":185},[171,598,189],{"class":181},[171,600,601],{"class":185},"\"AA\"",[171,603,604],{"class":181},", columns).bytes;   ",[171,606,607],{"class":198},"\u002F\u002F [27]\n",[171,609,611,613,615,617,619,622,625],{"class":173,"line":610},6,[171,612,399],{"class":177},[171,614,182],{"class":181},[171,616,209],{"class":185},[171,618,189],{"class":181},[171,620,621],{"class":185},"\"XFD\"",[171,623,624],{"class":181},", columns).bytes;  ",[171,626,627],{"class":198},"\u002F\u002F [64, 0], so 16384\n",[150,629,630,633],{},[154,631,632],{},"XFD"," is the last column Excel has. Now you know its number.",[150,635,636,637,640,641,643],{},"Zero encodes as ",[154,638,639],{},"\"0\"",", or as an empty string in bijective mode. Empty bytes encode as ",[154,642,639],{},".",[259,645,647],{"id":646},"can-identify-spot-a-whole-number","Can identify spot a whole number?",[150,649,650,651,654,655,657,658,661,662,665,666,668],{},"Every run of digits is a whole number. That's not much of a clue. ",[154,652,653],{},"identify"," only considers ",[154,656,148],{}," when it decodes to at least eight bytes of readable text. So ",[154,659,660],{},"3432"," can still be hex. And ",[154,663,664],{},"310939249775"," isn't guessed as ",[154,667,148],{},". Decode it by name.",[162,670,672],{"className":164,"code":671,"language":166,"meta":167,"style":167},"encode(\"integer\", \"attack at dawn\");                     \u002F\u002F \"1976620216402300889624482718775150\"\nidentify(\"1976620216402300889624482718775150\")[0]?.text; \u002F\u002F \"attack at dawn\"\n",[154,673,674,693],{"__ignoreMap":167},[171,675,676,678,680,682,684,687,690],{"class":173,"line":174},[171,677,178],{"class":177},[171,679,182],{"class":181},[171,681,209],{"class":185},[171,683,189],{"class":181},[171,685,686],{"class":185},"\"attack at dawn\"",[171,688,689],{"class":181},");                     ",[171,691,692],{"class":198},"\u002F\u002F \"1976620216402300889624482718775150\"\n",[171,694,695,697,699,702,705],{"class":173,"line":202},[171,696,653],{"class":177},[171,698,182],{"class":181},[171,700,701],{"class":185},"\"1976620216402300889624482718775150\"",[171,703,704],{"class":181},")[0]?.text; ",[171,706,707],{"class":198},"\u002F\u002F \"attack at dawn\"\n",[150,709,710,713],{},[154,711,712],{},"peel"," can confirm an integer layer too.",[162,715,717],{"className":164,"code":716,"language":166,"meta":167,"style":167},"peel(\"MTk3NjYyMDIxNjQwMjMwMDg4OTYyNDQ4MjcxODc3NTE1MA==\").map((layer) => layer.encoding);\n\u002F\u002F [\"base64\", \"integer\"], and the last layer's text is \"attack at dawn\"\n",[154,718,719,743],{"__ignoreMap":167},[171,720,721,723,725,728,731,734,737,740],{"class":173,"line":174},[171,722,712],{"class":177},[171,724,182],{"class":181},[171,726,727],{"class":185},"\"MTk3NjYyMDIxNjQwMjMwMDg4OTYyNDQ4MjcxODc3NTE1MA==\"",[171,729,730],{"class":181},").",[171,732,733],{"class":177},"map",[171,735,736],{"class":181},"((layer) ",[171,738,739],{"class":384},"=>",[171,741,742],{"class":181}," layer.encoding);\n",[171,744,745],{"class":173,"line":202},[171,746,747],{"class":198},"\u002F\u002F [\"base64\", \"integer\"], and the last layer's text is \"attack at dawn\"\n",[150,749,750,753,754,756,757,760,761,763,764,766,767,770],{},[154,751,752],{},"bigint"," is an alias for ",[154,755,148],{},". Need the codec alone? ",[154,758,759],{},"@agntn\u002Fencodings\u002Finteger"," exports ",[154,762,148],{},", and its ",[154,765,399],{}," hands back a ",[154,768,769],{},"Uint8Array"," straight away.",[150,772,773,774,777,778,780,781,189,784,189,787,790,791,643],{},"In the CLI, ",[154,775,776],{},"encodings encode integer Hello"," prints ",[154,779,664],{},". The options are flags: ",[154,782,783],{},"--radix",[154,785,786],{},"--digits",[154,788,789],{},"--bijective"," and ",[154,792,793],{},"--width",[795,796,797],"style",{},"html pre.shiki code .sK71F, html code.shiki .sK71F{--shiki-light:var(--shiki-token-function);--shiki-default:var(--shiki-token-function);--shiki-dark:var(--shiki-token-function)}html pre.shiki code .s38Sx, html code.shiki .s38Sx{--shiki-light:var(--ui-text-highlighted);--shiki-default:var(--ui-text-highlighted);--shiki-dark:var(--ui-text-highlighted)}html pre.shiki code .shU9J, html code.shiki .shU9J{--shiki-light:var(--shiki-token-string);--shiki-default:var(--shiki-token-string);--shiki-dark:var(--shiki-token-string)}html pre.shiki code .scIB-, html code.shiki .scIB-{--shiki-light:var(--shiki-token-comment);--shiki-default:var(--shiki-token-comment);--shiki-dark:var(--shiki-token-comment)}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .skH_V, html code.shiki .skH_V{--shiki-light:var(--shiki-token-keyword);--shiki-default:var(--shiki-token-keyword);--shiki-dark:var(--shiki-token-keyword)}",{"title":167,"searchDepth":202,"depth":202,"links":799},[800,801,802,803],{"id":261,"depth":202,"text":262},{"id":362,"depth":202,"text":363},{"id":467,"depth":202,"text":468},{"id":646,"depth":202,"text":647},"A whole number as bytes. Pick a base or bring your own digits","md",null,{},{"title":72,"description":804},"ACiLaL5dJ7Cd3AM1iaFMKKE3dLiHtRGMxqkgxqF7QnU",[811,813],{"title":68,"path":69,"stem":70,"description":812,"children":-1},"Numbers can be bytes or Unicode code points. Give the ASCII table some company",{"title":76,"path":77,"stem":78,"description":814,"children":-1},"Hex for bytes or Unicode code points. Your puzzle gets to choose",1794584245088]