Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: alenpowa on October 24, 2018, 03:07:59 PM



Title: Best data type for Bitcoin in go
Post by: alenpowa on October 24, 2018, 03:07:59 PM
Hey everybody, I was wondering what would be the best data type to use for bitcoin.
Both float32 and float64 are not recommended to use for money representation, what can be a valid solution?


Title: Re: Best data type for Bitcoin in go
Post by: Foxpup on October 24, 2018, 04:11:47 PM
What's wrong with int64? ???


Title: Re: Best data type for Bitcoin in go
Post by: alenpowa on October 24, 2018, 04:51:30 PM
As FoxPup mentioned, int64 is best choice since it's enough even to specify total Bitcoin supply (in Satoshi).

Additionally, it's easier to use/implement since not all software uses same double/float64 standard and AFAIK int64 is faster.

That's the issue, what if a conversion goes bad and a user gets in his balance 1000's of bitcoin?
is that what you mean?
https://play.golang.org/p/rJncvBvqyEP


Title: Re: Best data type for Bitcoin in go
Post by: Foxpup on October 24, 2018, 05:11:25 PM
That's the issue, what if a conversion goes bad and a user gets in his balance 1000's of bitcoin?
Computers only do what they're programmed to do; if "a conversion goes bad", it's because it was incompetently written and you should quit voodoo programming and hire someone who knows what they're doing for your project, especially if it involves handling other people's money. :-\


Title: Re: Best data type for Bitcoin in go
Post by: alenpowa on October 24, 2018, 05:12:53 PM
savage