Skip to content

Add toFloat, fix toInt truncation, and add MIN/MAX constants to Int64/Int32/UInt64#12836

Merged
Simn merged 3 commits intohaxe-numericfrom
copilot/sub-pr-12825
Mar 17, 2026
Merged

Add toFloat, fix toInt truncation, and add MIN/MAX constants to Int64/Int32/UInt64#12836
Simn merged 3 commits intohaxe-numericfrom
copilot/sub-pr-12825

Conversation

Copy link
Contributor

Copilot AI commented Mar 17, 2026

Addresses several gaps in the Int64/Int32/UInt64 API: missing toFloat, inconsistent toInt overflow behavior, and lack of MIN/MAX constants.

Int64.toFloat()

New instance method across all targets. Cross-platform and eval/C++ use high * 2^32 + unsigned_low; JVM and HL use native signed-to-float casts.

var v = Int64.parseString("9007199254740991");
trace(v.toFloat()); // 9007199254740991.0 (exact)

trace(Int64.MAX.toFloat()); // ~9.22e18

Int64.toInt() — silent truncation

Previously threw "Overflow" when the value exceeded 32-bit range. Now silently returns the low 32 bits, consistent with UInt64.toInt() and all other numeric types. Applied to all implementations (cross-platform, JVM, HL, eval, C++).

MIN/MAX constants

Added static final MIN and static final MAX to haxe.Int64, haxe.Int32, and haxe.UInt64:

Type MIN MAX
Int64 -2^63 2^63 - 1
Int32 -2^31 2^31 - 1
UInt64 0 2^64 - 1

Tests

  • TestInt64: removed overflow-throw expectations, added testToFloat and testMinMax
  • TestInt32: both test files updated to reference Int32.MAX/Int32.MIN; added testMinMax
  • TestUInt64: added testMinMax

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Co-authored-by: Simn <634365+Simn@users.noreply.github.com>
Copilot AI changed the title [WIP] Unify numeric types API across all targets Add toFloat, fix toInt truncation, and add MIN/MAX constants to Int64/Int32/UInt64 Mar 17, 2026
Copilot AI requested a review from Simn March 17, 2026 15:24
Copilot finished work on behalf of Simn March 17, 2026 15:24
@Simn Simn marked this pull request as ready for review March 17, 2026 15:44
@Simn Simn merged commit 27dff2b into haxe-numeric Mar 17, 2026
60 checks passed
@Simn Simn deleted the copilot/sub-pr-12825 branch March 17, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants