Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Create UInt64 from UInt32 #855

Open
iskiselev opened this issue Sep 17, 2015 · 1 comment
Open

Create UInt64 from UInt32 #855

iskiselev opened this issue Sep 17, 2015 · 1 comment

Comments

@iskiselev
Copy link
Member

JSIL translated code fails on next test case:

using System;

public static class Program {
    public static void Main (string[] args)
    {
        ulong l = 0x80000000;
        Console.WriteLine(l);
    }
}

It fails with Error: cannot construct UInt64 from negative number.
This code was translated to:

var $T02 = function () {
    return ($T02 = JSIL.Memoize($asm01.System.UInt64)) ();
  };
    $T01().WriteLine($T02().FromNumber(-2147483648));

So, probably we should allow creation of UInt64 from negative numbers with built-in conversion or fix how JSIL translates it.

@markusjohnsson
Copy link
Contributor

Yup, FromNumber should probably interpret -2147483648 as a 32 bit int, take the bits from that and treat it as a 32 bit uint.

See conv_u8: https://github.com/markusjohnsson/cil.js/blob/master/CilJs/Runtime/Runtime.js#L363

iskiselev added a commit to iskiselev/JSIL that referenced this issue Sep 18, 2015
iskiselev added a commit to iskiselev/JSIL that referenced this issue Sep 18, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants