Skip to content

Commit

Permalink
Add Float64() helper converters to BigInt and BigUInt
Browse files Browse the repository at this point in the history
  • Loading branch information
James Alavosus committed Apr 25, 2021
1 parent 8972f17 commit 7963429
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bigint.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ func (b BigInt) Int64() int64 {
return int64(b)
}

// Float64 returns the float64 representation of b
func (b BigInt) Float64() float64 {
return float64(b.Int64())
}

// MarshalGQL implements the graphql.Marshaler interface found in
// gqlgen, allowing the type to be marshaled by gqlgen and sent over
// the wire.
Expand Down
5 changes: 5 additions & 0 deletions biguint.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ func (b BigUInt) UInt64() uint64 {
return uint64(b)
}

// Float64 returns the float64 representation of b
func (b BigUInt) Float64() float64 {
return float64(b.UInt64())
}

// MarshalGQL implements the graphql.Marshaler interface found in
// gqlgen, allowing the type to be marshaled by gqlgen and sent over
// the wire.
Expand Down

0 comments on commit 7963429

Please sign in to comment.