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

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -