ccxvii / mujs

An embeddable Javascript interpreter in C.

Home Page:http://mujs.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Negative numbers converted to positive integers

gardhr opened this issue · comments

Example:

var val = -1
print("val:", val)

Output:

val: 4294967295

The fact that it returns 2^32 - 1 makes me wonder because I've redefined jsInstruction to long. Maybe that's the problem?

Yeah wrong instruction type usually leads to the problem, i had same issue when i defined it as unsigned int, but setting it to just int did the trick.

Looks like it just needs to be a signed number. Changed it from "unsigned long" to "long" and everything works just fine now.