Smartcontract (#39)
* deleted transfer_output added asset type and transaction result to core * removed writing 0x00 when buffer length is 0 * Refactored emit into VM package + moved tx to own package. * implemented transaction along with claimTransaction. * refactored naming of transaction + added decode address for uint160 types * removed unnecessary folder and files. * transaction/smartcontract logic * bumped version 0.24.0
This commit is contained in:
parent
42195b1af4
commit
1a1a19da7d
36 changed files with 1066 additions and 170 deletions
31
pkg/util/fixed8.go
Normal file
31
pkg/util/fixed8.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Fixed8 represents a fixed-point number with precision 10^-8.
|
||||
type Fixed8 int64
|
||||
|
||||
// String implements the Stringer interface.
|
||||
func (f Fixed8) String() string {
|
||||
buf := new(bytes.Buffer)
|
||||
val := int64(f)
|
||||
if val < 0 {
|
||||
buf.WriteRune('-')
|
||||
val = -val
|
||||
}
|
||||
str := strconv.FormatInt(val/100000000, 10)
|
||||
buf.WriteString(str)
|
||||
val %= 100000000
|
||||
if val > 0 {
|
||||
buf.WriteRune('.')
|
||||
str = strconv.FormatInt(val, 10)
|
||||
for i := len(str); i < 8; i++ {
|
||||
buf.WriteRune('0')
|
||||
}
|
||||
buf.WriteString(str)
|
||||
}
|
||||
return buf.String()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue