Advertisement
Koepnick

numerics to strings

Jan 15th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.59 KB | None | 0 0
  1. // Display an integer in other bases
  2. i := 5
  3. strconv.FormatInt(i, 2)
  4. strconv.FormatUint(i, 2)
  5.  
  6. b := true
  7. strconv.FormatBool(b)               // True
  8.  
  9. j := 2.5
  10. strconv.FormatFloat(j, 'E', -1, 32) // 'E' 2.5E+00, 'e' 2.5e00, 'f' 2.5, 'g' 2.5, 'G' 2.5
  11.                                     //    'g' and 'G' will behave like 'e' and 'E' with large exponents
  12.                                     // Number of digits, -1 is a special value that returns
  13.                                     //    the minimum number of digits for an exact value
  14.                                     // Variable size
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement