mirror of https://github.com/tinygo-org/tinygo.git
Ayke van Laethem
6 years ago
2 changed files with 39 additions and 0 deletions
@ -0,0 +1,26 @@ |
|||||
|
package main |
||||
|
|
||||
|
func main() { |
||||
|
// sanity
|
||||
|
println(3.14159265358979323846) |
||||
|
|
||||
|
// float64
|
||||
|
f64 := float64(2) / float64(3) |
||||
|
println(f64) |
||||
|
println(f64 + 1.0) |
||||
|
println(f64 - 1.0) |
||||
|
println(f64 * 2.0) |
||||
|
println(f64 / 2.0) |
||||
|
|
||||
|
// float32
|
||||
|
f32 := float32(2) / float32(3) |
||||
|
println(f32) |
||||
|
println(f32 + 1.0) |
||||
|
println(f32 - 1.0) |
||||
|
println(f32 * 2.0) |
||||
|
println(f32 / 2.0) |
||||
|
|
||||
|
// casting
|
||||
|
println(float32(f64)) |
||||
|
println(float64(f32)) |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
+3.141593e+000 |
||||
|
+6.666667e-001 |
||||
|
+1.666667e+000 |
||||
|
-3.333333e-001 |
||||
|
+1.333333e+000 |
||||
|
+3.333333e-001 |
||||
|
+6.666667e-001 |
||||
|
+1.666667e+000 |
||||
|
-3.333333e-001 |
||||
|
+1.333333e+000 |
||||
|
+3.333333e-001 |
||||
|
+6.666667e-001 |
||||
|
+6.666667e-001 |
Loading…
Reference in new issue