Created
November 29, 2023 20:13
-
-
Save rootulp/8ab69ea824f796926320322e62aa2ed8 to your computer and use it in GitHub Desktop.
Go playground to conver a quantity of utia to TIA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
// utiaPerTia is the number of utia in one TIA | |
// see https://docs.celestia.org/learn/tia#tia-display-token | |
const utiaPerTia = int64(1_000_000) | |
func main() { | |
// feel free to modify utia | |
utia := int64(1) | |
fmt.Printf("%v utia\n", utia) | |
fmt.Printf("%v TIA\n", formatAsTia(utia)) | |
} | |
func formatAsTia(utia int64) string { | |
tia := float64(utia) / float64(utiaPerTia) | |
return fmt.Sprintf("%.6f", tia) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://go.dev/play/p/5EKFzxn-S23