sq / JSIL

CIL to Javascript Compiler

Home Page:http://jsil.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ulong math is incorrect

ghent360 opened this issue · comments

Sample code, entered in try.jsil.com

using System;
public static class Program {
public static void Main () {
ulong x64 = 2 << 47;
ulong y64 = x64 << 5;
Console.WriteLine("Hello JSIL World!");
Console.WriteLine("{0}, {1}", x64, y64);
}
}

Generated code:
...
(function Program$Members () {
var $, $thisType;
var $T00 = function () {
return ($T00 = JSIL.Memoize($asm01.System.Console)) ();
};
var $T01 = function () {
return ($T01 = JSIL.Memoize($asm01.System.UInt64)) ();
};

function Program_Main () {
$T00().WriteLine("Hello JSIL World!");
$T00().WriteLine(
"{0}, {1}",
$T01().Create(65536, 0, 0),
$T01().op_LeftShift($T01().Create(65536, 0, 0), 5)
);
};

JSIL.MakeStaticClass("Program", true, [], function ($interfaceBuilder) {
$ = $interfaceBuilder;

$.Method({Static:true , Public:true }, "Main", 
  JSIL.MethodSignature.Void, 
  Program_Main
);

return function (newThisType) { $thisType = newThisType; }; 

});

})();

Output:
Hello JSIL World!
65536, 2097152

Expected:
Hello JSIL World!
140737488355328, 4503599627370496

Your example program produces the same output on JSIL and .NET 4.5 (try for example dotnetfiddle.net). Where did you run it to get the expected output?

Sorry, my mistake. Should have been 1L << 47;
It works fine when I fix the code.