urbit-ob

JavaScript utilities for phonemic base wrangling.
Log | Files | Refs | README

commit 8b3ce93b65855b8f3815bbed3e9c89e733992803
parent af13d68f96b70c16c5b2073555ac119e90e6f515
Author: Anthony <anthony@ai.co>
Date:   Sun,  5 Nov 2017 09:52:35 -0800

fixed num to shipname

Diffstat:
Mnom.js | 14+++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/nom.js b/nom.js @@ -61,13 +61,14 @@ var wordtonum = function(word) { var feen = function(pyn) { console.log('feen input', pyn); if (pyn >= 0x10000 && pyn <= 0xFFFFFFFF) { - var tmp = fice(pyn - 0x10000); + var tmp = fice(pyn - 0x10000) + 0x10000; console.log('output of feen', tmp); return tmp; } if (pyn >= 0x100000000 && pyn <= 0xffffffffffffffff) { var lo = pyn & 0xFFFFFFFF; var hi = pyn & 0xffffffff00000000; + console.log('feen recursion'); return bn(hi).or(feen(lo)); } console.log('output of feen', pyn); @@ -92,6 +93,7 @@ var fend = function(cry) { }; var fice = function(nor) { + console.log('input to fice', nor); var sel = [ nor % 65535, nor / 65535 @@ -123,12 +125,14 @@ var teil = function(vip) { }; var rynd = function(n, l, r) { + //console.log('input to rynd', n, l, r); var res = [r, 0]; var m = 0x10000; if (n % 2 == 0) { m = 0xFFFF; }; - res[1] = (l + muk(raku[n], 2, r)) % m; + res[1] = (bn(muk(raku[n], 2, r)).add(l)) % m; + console.log('output to rynd', res); return res; }; @@ -320,13 +324,17 @@ var toShipName = function(addr, minBytes, scramble) { var name = "" for (var i = 0; i < minBytes; i ++) { - var byt = addr % 256; + var byt = Math.floor(addr % 256); + console.log('byt', byt); var syllable = ""; if (i % 2 == 1) { syllable = getprefix(byt); } else { syllable = getsuffix(byt); } + if (i == 2) { + name = "-" + name + }; name = syllable + name; addr = addr / 256; };