Added a lot to the interpreter, but some odd problem where snprintf seems to print the wrong thing something like a 10th of the time. Debugged it for a while over two days, and I've narrowed it down to the actual snprintf call. It seems to happen under some different circumstances for compiled versions too, so I'm just going to keep it like this for now.

This commit is contained in:
Nathan Braswell
2016-05-18 23:11:00 -07:00
parent 4dcd4f9715
commit ce1afa45f4
4 changed files with 115 additions and 64 deletions

View File

@@ -38,13 +38,14 @@ fun print(toPrint: bool): void {
return;
}
ext fun sprintf(to_str: *char, format: *char, d: double)
ext fun snprintf(to_str: *char, num: ulong, format: *char, d: double): int
fun print(toPrint: float)
print((toPrint) cast double)
fun print(toPrint: double) {
var int_str = new<char>((#sizeof<double>) cast int)
sprintf(int_str, "%f", toPrint)
var how_much = snprintf(null<char>(), (0) cast ulong, "%f", toPrint)
var int_str = new<char>(how_much+2)
snprintf(int_str, (how_much+1) cast ulong, "%f", toPrint)
print(int_str)
delete(int_str)
}