why not use i32 replace int? #15375
Replies: 4 comments
-
@Silentdoer OCD may be unbearable 😄 |
Beta Was this translation helpful? Give feedback.
-
I can use them interchangeably without a problem. I don't know if this should be the case tho. fn main() {
mut test := int(1)
mut test2 := i32(1)
if test == test2 {
println("they are equal")
} else {
println("they are different")
}
test = return_i32(5)
test2 = return_int(5)
if test == test2 {
println("they are equal")
} else {
println("they are different")
}
}
fn return_int(num int) int {
return int(num)
}
fn return_i32(num int) i32 {
return i32(num)
} |
Beta Was this translation helpful? Give feedback.
-
Kind of like it that way, where int or i32 can be used. "int" is so common in people's mind, it's almost like a tradition. Likely to get, "Where is int?" or "Save the int!". So perhaps its for the best. |
Beta Was this translation helpful? Give feedback.
-
In C Even today do you care most of the time if an integer is 32 bits or 64 bits? Unless you're dealing with code that handles very large integers it's unlikely to matter. And if it truly matters you may need to use a special math library to use complex 128-bit numbers as well. Only when dealing with embedded systems do we really need to worry about the size of an |
Beta Was this translation helpful? Give feedback.
-
it's not consistent with other number type
Beta Was this translation helpful? Give feedback.
All reactions