Skip to content

Add BigRational#to_i#15809

Merged
straight-shoota merged 1 commit intocrystal-lang:masterfrom
HertzDevil:feature/bigrational-to_i
May 26, 2025
Merged

Add BigRational#to_i#15809
straight-shoota merged 1 commit intocrystal-lang:masterfrom
HertzDevil:feature/bigrational-to_i

Conversation

@HertzDevil
Copy link
Contributor

This is the only type in the standard library where #to_i32 is already defined but #to_i isn't.

This makes BigRational suspectible to precision loss when passed to sprintf %i (see also #15808), since BigRational#to_i32 currently delegates to #to_f64 instead of #to_big_i. However this is still an improvement over the current situation where BigRational isn't supported by sprintf at all.

@straight-shoota straight-shoota added this to the 1.17.0 milestone May 22, 2025
@straight-shoota straight-shoota merged commit 752c525 into crystal-lang:master May 26, 2025
43 of 44 checks passed
@HertzDevil HertzDevil deleted the feature/bigrational-to_i branch May 26, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants