github.com/iotexproject/iotex-core@v1.14.1-rc1/pkg/unit/unit.go (about) 1 // Copyright (c) 2019 IoTeX Foundation 2 // This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability 3 // or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed. 4 // This source code is governed by Apache License 2.0 that can be found in the LICENSE file. 5 6 package unit 7 8 import ( 9 "math/big" 10 ) 11 12 const ( 13 // Rau is the smallest non-fungible token unit 14 Rau int64 = 1 15 // KRau is 1000 Rau 16 KRau = Rau * 1000 17 // MRau is 1000 KRau 18 MRau = KRau * 1000 19 // GRau is 1000 MRau 20 GRau = MRau * 1000 21 // Qev is 1000 GRau 22 Qev = GRau * 1000 23 // Jin is 1000 Qev 24 Jin = Qev * 1000 25 // Iotx is 1000 Jin, which should be fit into int64 26 Iotx = Jin * 1000 27 ) 28 29 // ConvertIotxToRau converts an Iotx to Rau 30 func ConvertIotxToRau(iotx int64) *big.Int { 31 itx := big.NewInt(iotx) 32 return itx.Mul(itx, big.NewInt(1e18)) 33 }