-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integer data type #101
base: master
Are you sure you want to change the base?
Integer data type #101
Conversation
That already happen on supported targets (C++, HL, C#, etc) I'm also not a fan of the compiler implicitly deciding of the integer type.
This would be nice, but again, we need to be careful about target-specific behavior. |
In practical is very rarely to use Int above 2147483647, so to not loose performance the current behaviour could be kept i.e. default Int (according to the target) and if someone want consistent overflow behaviour to use Int32. Int64 for Javascript could be a tricky one. Using Bigint for replacement could lead to loose of performance. I did some test for : Int64 (Haxe) , BigInt (JS) and Float ( Haxe) . The float give wrong result. BigInt give better performance than the current Int64 abstract class. Here is the example: https://try.haxe.org/#669Ae823
Default Int looks as a good solution . The other one could be to to use only signed integer values i.e Int < Int64 < BigInt depending of the value. Adding UIn64 will be nice addition. Some target already have a native one ( C/C++ - unsigned long long ; C# - ulong; ) for other could be emulated or used BigInteger. |
Added questions about conversion between types and Int vs. Int32 types
Conversion between Float and Integer types
Adding Int8 (sbyte) and UInt8 (byte) types Adding Int16 and UInt16
Update
The following changes are now suggested for this proposal:
Sometimes it is not so easy to work with Int64 types in Haxe. Recently anounced literal suffix and number separator make things better , but real support for Int64 ( replacing abstract class with the native for the target) will give better performace and will lead to more clean code.
For example
and not
var v:Int64 = Int64.make(0x7FFFFFFF,0xFFFFFFFF);
Well with nigth build it could be
var v:Int64 = 0x7FFFFFFFFFFFFFFF_i64
, but still to be good to have option without suffix.Other things could be adding universal UIn64 and unification of Int and Int32 types.
Rendered version