Bitcoin Forum
May 08, 2024, 02:59:52 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Best data type for Bitcoin in go  (Read 146 times)
alenpowa (OP)
Newbie
*
Offline Offline

Activity: 92
Merit: 0


View Profile
October 24, 2018, 03:07:59 PM
 #1

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?
1715180392
Hero Member
*
Offline Offline

Posts: 1715180392

View Profile Personal Message (Offline)

Ignore
1715180392
Reply with quote  #2

1715180392
Report to moderator
1715180392
Hero Member
*
Offline Offline

Posts: 1715180392

View Profile Personal Message (Offline)

Ignore
1715180392
Reply with quote  #2

1715180392
Report to moderator
1715180392
Hero Member
*
Offline Offline

Posts: 1715180392

View Profile Personal Message (Offline)

Ignore
1715180392
Reply with quote  #2

1715180392
Report to moderator
Remember that Bitcoin is still beta software. Don't put all of your money into BTC!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715180392
Hero Member
*
Offline Offline

Posts: 1715180392

View Profile Personal Message (Offline)

Ignore
1715180392
Reply with quote  #2

1715180392
Report to moderator
Foxpup
Legendary
*
Offline Offline

Activity: 4354
Merit: 3044


Vile Vixen and Miss Bitcointalk 2021-2023


View Profile
October 24, 2018, 04:11:47 PM
 #2

What's wrong with int64? Huh

Will pretend to do unspeakable things (while actually eating a taco) for bitcoins: 1K6d1EviQKX3SVKjPYmJGyWBb1avbmCFM4
I am not on the scammers' paradise known as Telegram! Do not believe anyone claiming to be me off-forum without a signed message from the above address! Accept no excuses and make no exceptions!
alenpowa (OP)
Newbie
*
Offline Offline

Activity: 92
Merit: 0


View Profile
October 24, 2018, 04:51:30 PM
 #3

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
Foxpup
Legendary
*
Offline Offline

Activity: 4354
Merit: 3044


Vile Vixen and Miss Bitcointalk 2021-2023


View Profile
October 24, 2018, 05:11:25 PM
 #4

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. Undecided

Will pretend to do unspeakable things (while actually eating a taco) for bitcoins: 1K6d1EviQKX3SVKjPYmJGyWBb1avbmCFM4
I am not on the scammers' paradise known as Telegram! Do not believe anyone claiming to be me off-forum without a signed message from the above address! Accept no excuses and make no exceptions!
alenpowa (OP)
Newbie
*
Offline Offline

Activity: 92
Merit: 0


View Profile
October 24, 2018, 05:12:53 PM
 #5

savage
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!