Skip to content

Instantly share code, notes, and snippets.

@rootulp
Created November 29, 2023 20:13
Show Gist options
  • Save rootulp/8ab69ea824f796926320322e62aa2ed8 to your computer and use it in GitHub Desktop.
Save rootulp/8ab69ea824f796926320322e62aa2ed8 to your computer and use it in GitHub Desktop.
Go playground to conver a quantity of utia to TIA
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)
}
@rootulp
Copy link
Author

rootulp commented Nov 29, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment