Skip to content

Commit

Permalink
rename to_unchecked_x (#1298)
Browse files Browse the repository at this point in the history
Co-authored-by: Haoxiang Fei <[email protected]>
  • Loading branch information
Yoorkin and tonyfettes authored Dec 9, 2024
1 parent 53ad7e2 commit 7228b15
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions builtin/bigint_nonjs.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ pub fn to_string(self : BigInt) -> String {
// This is an approximation of the number of slots needed to represent the decimal value.
let decimal_len = ((self.len * radix_bit_len).to_double() *
decimal_ratio /
decimal_radix_bit_len.to_double()).unchecked_to_int() +
decimal_radix_bit_len.to_double()).to_unchecked_int() +
1
let s = if self.sign == Negative { "-" } else { "" }
let v = Array::make(decimal_len, 0L)
Expand Down Expand Up @@ -637,7 +637,7 @@ pub fn BigInt::from_string(input : String) -> BigInt {
}
let sign : Sign = if input[0] == '-' { Negative } else { Positive }
let mut b_len = (
(len.to_double() / decimal_ratio).unchecked_to_int() + 1 + radix_bit_len
(len.to_double() / decimal_ratio).to_unchecked_int() + 1 + radix_bit_len
) /
radix_bit_len +
1
Expand Down
2 changes: 1 addition & 1 deletion builtin/double.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ pub fn Double::to_int(self : Double) -> Int {
} else if self <= -2147483648 {
-2147483648
} else {
self.unchecked_to_int()
self.to_unchecked_int()
}
}
2 changes: 1 addition & 1 deletion builtin/intrinsics.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub fn Double::compare(self : Double, other : Double) -> Int = "%f64_compare"
pub fn Double::default() -> Double = "%f64_default"

///|
fn Double::unchecked_to_int(self : Double) -> Int = "%f64_to_i32"
fn Double::to_unchecked_int(self : Double) -> Int = "%f64_to_i32"

///|
pub fn Double::convert_uint(val : UInt) -> Double = "%u32.to_f64"
Expand Down
4 changes: 2 additions & 2 deletions float/float.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn Float::default() -> Float {
}

///|
fn Float::unchecked_to_int(self : Float) -> Int = "%f32.to_i32"
fn Float::to_unchecked_int(self : Float) -> Int = "%f32.to_i32"

///|
/// Converts a floating-point number to an integer, with proper handling of
Expand Down Expand Up @@ -81,6 +81,6 @@ pub fn Float::to_int(self : Float) -> Int {
} else if self <= -2147483648 {
-2147483648
} else {
self.unchecked_to_int()
self.to_unchecked_int()
}
}

0 comments on commit 7228b15

Please sign in to comment.