HaxeFoundation / HaxeFoundation/haxe

Int64.modInt and intMod

Open
#9,958 1 comment 0 reactions 0 assignees View on GitHub
bug feature-abstracts
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

Code from `haxe/Int64.hx`
```haxe
@:op(A % B) private static inline function modInt(a:Int64, b:Int):Int64
return mod(a, b).toInt();

@:op(A % B) private static inline function intMod(a:Int, b:Int64):Int64
return mod(a, b).toInt();
```

Looks like return type should be `Int` or `.toInt()` should not be there. Otherwise this should lead to converting Int64 to Int and than back to Int64.

Also it looks like these functions are actually never called.
```haxe
//this haxe code:
var a: Int64 = Int64.fromFloat(100);
var b: Int64 = a % 10;
//compiles to this js code:
var a = haxe_Int64Helper.fromFloat(100);
var this1 = new haxe__$Int64__$_$_$Int64(0,10);
var b = haxe_Int64.divMod(a,this1).modulus;
```
but
```haxe
// this haxe code:
var a: Int64 = Int64.fromFloat(100);
var b: Int64 = @:privateAccess Int64.modInt(a, 10) ;
// compiles to this js code:
var a = haxe_Int64Helper.fromFloat(100);
var this1 = new haxe__$Int64__$_$_$Int64(0,10);
var x = haxe_Int64.divMod(a,this1).modulus;
if(x.high != x.low >> 31) {
throw haxe_Exception.thrown("Overflow");
}
var x1 = x.low;
var this1 = new haxe__$Int64__$_$_$Int64(x1 >> 31,x1);
var b = this1;

```

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.