Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

rust u32 to f64

//i32:
my_i32 as u32;		// To u32
my_i32.to_string();	// To string
my_i32 as f64;		// To f64

//u32:
my_u32 as i32;		// To i32
my_u32.to_string();	// To string
my_u32 as f64;		// To f64

//f64
my_f64 as i32;		// To i32
my_f64 as u32;		// To u32
my_f64.to_string();	// To string

//String (be mindful of type inference)
my_string.parse().unwrap()		// To i32
my_string.parse().unwrap()		// To u32
my_string.parse().unwrap()		// To f64
// In case the inference is not enough, you can clue rust in by giving it a hint
// example:
my_string.parse::<i32>().unwrap();
// But usually that isn't necessary
Source by carols10cents.github.io #
 
PREVIOUS NEXT
Tagged: #rust
ADD COMMENT
Topic
Name
5+8 =