From 79634296c1b0c9941756e3c9820d3a252c225547 Mon Sep 17 00:00:00 2001 From: James Alavosus Date: Sun, 25 Apr 2021 02:35:39 -0400 Subject: [PATCH] Add Float64() helper converters to BigInt and BigUInt --- bigint.go | 5 +++++ biguint.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/bigint.go b/bigint.go index 9be9e12..912bc3d 100644 --- a/bigint.go +++ b/bigint.go @@ -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. diff --git a/biguint.go b/biguint.go index 6031299..8bab9c2 100644 --- a/biguint.go +++ b/biguint.go @@ -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.