javascript - Converting between int[ish] and double[ish] in asm.js -
if need to, say, find the integer part , fractional part of number within asm.js module, how do it? none of standard operators convert between intish , doubleish types; math.floor returns double, , result can't coerced int.
var floor = stdlib.math.floor; function(n) { n = +n; var = 0; = floor(n)|0; // fails: "operands bitwise ops must intish" var b = 0.0; b = +(n-a); // fail if compiler got here return; }
vyacheslav egorov (twitter:@mraleph) says: use ~~ coerce int. special validation case: http://asmjs.org/spec/latest/#unaryexpression
a = ~~floor(n); // success!
Comments
Post a Comment