官术网_书友最值得收藏!

  • Learning Rust
  • Paul Johnson Vesa Kaihlavirta
  • 91字
  • 2021-07-02 23:07:15

Float

Much as with other languages, floating point arithmetic can be performed in Rust. As with an integer variable, a floating point variable is defined for a 32-bit float as follows:

let pi = 3.14f32; 

For a 64-bit float, it will be defined as this:

let pi = 3.14f64; 

The variables are literal values. Another way to declare the size would be via types:

let pi: f32 = 3.14; 

If a type is omitted (for example, let x = 3.14), the variable will be declared as a 64-bit floating point variable.

主站蜘蛛池模板: 遵义县| 林州市| 阳谷县| 石台县| 恭城| 普兰店市| 宜阳县| 繁峙县| 镇赉县| 江油市| 凤翔县| 怀来县| 沈丘县| 循化| 桃源县| 屏东县| 云南省| 山西省| 陕西省| 威远县| 长寿区| 武汉市| 抚顺县| 彰化市| 黄大仙区| 恩平市| 平原县| 黑龙江省| 游戏| 灌阳县| 吴桥县| 秦安县| 娄底市| 和静县| 潼关县| 奉贤区| 延长县| 句容市| 岐山县| 武义县| 枞阳县|