HaxeFoundation / HaxeFoundation/haxe

Something wrong with Float64Array? in all targets but javascript?

Open
#5,273 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

This code yields different results on javascript and others targets.
It seem that other targets than javascript writes the same as a float32. Not sure why.

```
class Demo {
static private var _tempBytes = haxe.io.Bytes.alloc(8);
static private var _tempI8 = haxe.io.UInt8Array.fromBytes(_tempBytes);
static private var _tempF32 = haxe.io.Float32Array.fromBytes(_tempBytes);
static private var _tempI32 = haxe.io.Int32Array.fromBytes(_tempBytes);
static private var _tempF64 = haxe.io.Float64Array.fromBytes(_tempBytes);
static public function main() {
testF32();
testF64();
}
static private function testF32() {
trace('----');
_tempF32[0] = 1.0;
var i1 = _tempI32[1];
var i2 = _tempI32[0];
for (n in 0 ... 8) trace(_tempI8[n]);
trace('' + haxe.Int64.make(i1, i2)); // yields invalid value on PHP and Neko. Right value on nodejs
//trace(haxe.Int64.make(i1, i2)); // fails on javascript (Demo.hx:10: characters 2-7 : Cannot access private field toString)
}
static private function testF64() {
trace('----');
_tempF64[0] = 1.0;
var i1 = _tempI32[1];
var i2 = _tempI32[0];
for (n in 0 ... 8) trace(_tempI8[n]);
trace('' + haxe.Int64.make(i1, i2)); // yields invalid value on PHP and Neko. Right value on nodejs
//trace(haxe.Int64.make(i1, i2)); // fails on javascript (Demo.hx:10: characters 2-7 : Cannot access private field toString)
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.