Golang : micron to centimeter example
Problem:
You need to convert centimeter to micron (µ) in Golang. How to do that?
Solution:
Simple. See the following code:
package main
import (
"fmt"
)
func micron2cm(µ float64) float64 {
return µ / 10000
}
func cm2micron(cm float64) float64 {
return cm * 10000
}
func main() {
fmt.Println("10 µ in centimeter is : ", micron2cm(10.0))
fmt.Println(micron2cm(10.0), " centimeter in µ :", cm2micron(micron2cm(10.0)))
}
Output:
10 µ in centimeter is : 0.001
0.001 centimeter in µ : 10
References:
http://www.allmeasures.com/Fullconversion.asp
https://socketloop.com/tutorials/golang-temperatures-conversion-example
See also : Golang : Temperatures conversion example
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+6.3k CodeIgniter : form input set_value cause " to become & quot
+9.4k Golang : Read file with ioutil
+5.4k Golang : If else example and common mistake
+11.8k Golang : Determine if time variables have same calendar day
+6.6k Golang : Humanize and Titleize functions
+19.9k Golang : Reset or rewind io.Reader or io.Writer
+33.7k Golang : convert(cast) bytes to string
+15.4k Golang : rune literal not terminated error
+14.7k Golang : How to check for empty array string or string?
+11.3k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+8.2k Golang : Number guessing game with user input verification example
+16.3k Golang : Execute terminal command to remote machine example