Bitcoin Forum
December 08, 2016, 12:04:54 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1] 2 3 »  All
  Print  
Author Topic: mtgox, please fix your rounding bugs  (Read 5609 times)
davout
Legendary
*
Offline Offline

Activity: 1358


1davout


View Profile WWW
November 19, 2010, 02:41:35 PM
 #1

See screenshot, this kind of stuff happens a lot.

1481198694
Hero Member
*
Offline Offline

Posts: 1481198694

View Profile Personal Message (Offline)

Ignore
1481198694
Reply with quote  #2

1481198694
Report to moderator
1481198694
Hero Member
*
Offline Offline

Posts: 1481198694

View Profile Personal Message (Offline)

Ignore
1481198694
Reply with quote  #2

1481198694
Report to moderator
1481198694
Hero Member
*
Offline Offline

Posts: 1481198694

View Profile Personal Message (Offline)

Ignore
1481198694
Reply with quote  #2

1481198694
Report to moderator
There are several different types of Bitcoin clients. Server-assisted clients like blockchain.info rely on centralized servers to do their network verification for them. Although the server can't steal the client's bitcoins directly, it can easily execute double-spending-style attacks against the client.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481198694
Hero Member
*
Offline Offline

Posts: 1481198694

View Profile Personal Message (Offline)

Ignore
1481198694
Reply with quote  #2

1481198694
Report to moderator
1481198694
Hero Member
*
Offline Offline

Posts: 1481198694

View Profile Personal Message (Offline)

Ignore
1481198694
Reply with quote  #2

1481198694
Report to moderator
ShadowOfHarbringer
Legendary
*
Offline Offline

Activity: 1470


Bringing Legendary Har® to you since 1952


View Profile
November 19, 2010, 02:52:59 PM
 #2

I don't know if mtgox knows or uses this, but PHP has special set of functions for this kind of things - it's called BC_MATH.

http://www.php.net/manual/en/book.bc.php

With it, it is possible to count any number with any needed precision.

davout
Legendary
*
Offline Offline

Activity: 1358


1davout


View Profile WWW
November 19, 2010, 02:59:56 PM
 #3

Also *never* use float column sql data types, when storing money values decimal is the way to go.
Edit : <troll>Also never use PHP</troll>

ribuck
Donator
Legendary
*
Offline Offline

Activity: 826


View Profile
November 19, 2010, 03:06:13 PM
 #4

<troll>Also never use PHP</troll>

Indeed that's a troll. PHP offers all the tools you need to program sound decimal arithmetic.

PHP is inelegant, but it's capable and ubiquitous. A good software engineer can implement great systems with PHP if they need to.
ShadowOfHarbringer
Legendary
*
Offline Offline

Activity: 1470


Bringing Legendary Har® to you since 1952


View Profile
November 19, 2010, 03:12:35 PM
 #5

Also *never* use float column sql data types, when storing money values decimal is the way to go.

Precisely, i believe that in PHP it may be best to store floats as pure strings, and convert them when necessary. There were some nasty bugs in float-to-float comparisons in PHP, i don't remember if they fixed them all.

davout
Legendary
*
Offline Offline

Activity: 1358


1davout


View Profile WWW
November 19, 2010, 03:59:06 PM
 #6

Also *never* use float column sql data types, when storing money values decimal is the way to go.

Precisely, i believe that in PHP it may be best to store floats as pure strings, and convert them when necessary. There were some nasty bugs in float-to-float comparisons in PHP, i don't remember if they fixed them all.

You have it wrong, floats are not supposed to be used to store exact values, decimal types are designed for that purpose



<troll>Also never use PHP</troll>
Indeed that's a troll. PHP offers all the tools you need to program sound decimal arithmetic.

PHP is inelegant, but it's capable and ubiquitous. A good software engineer can implement great systems with PHP if they need to.

Just as a good math student can compute a block's hash with a pencil and some paper if he needs to.
Anyway, that's absolutely not the point, I respect PHP for what it is, a performant language that's really easy to learn. Personnally I switched for Rails years ago.

Anyway, I think the rounding issues probably would have been the same if coded in RoR without careful design and knowledge of the exact values handling good practices.


mtgox
Full Member
***
Offline Offline

Activity: 185


View Profile WWW
November 19, 2010, 06:07:12 PM
 #7

davout: It is just a display issue. You really have something like $11.487 in your account. So just withdraw one penny less. I'm not using floats to store the account balances.   I suppose I should just floor the amount displayed.

ribuck
Donator
Legendary
*
Offline Offline

Activity: 826


View Profile
November 19, 2010, 06:14:08 PM
 #8

I suppose I should just floor the amount displayed.
No, you should display the actual balance. If the real balance has three digits after the decimal, you should show three digits.
kiba
Legendary
*
Offline Offline

Activity: 980


View Profile
November 19, 2010, 06:18:02 PM
 #9

Also, can you please automatically calculate the fee?

nanotube
Hero Member
*****
Offline Offline

Activity: 485


View Profile WWW
November 19, 2010, 07:47:31 PM
 #10

+1 on showing actual balances without rounding.

+1 on pre-calculating the fee that would be charged, and showing it to the user to see before submitting an order.

Join #bitcoin-market on freenode for real-time market updates.
Join #bitcoin-otc - an over-the-counter trading market. http://bitcoin-otc.com
OTC web of trust: http://bitcoin-otc.com/trust.php
My trust rating: http://bitcoin-otc.com/viewratingdetail.php?nick=nanotube
bitcoinex
Sr. Member
****
Offline Offline

Activity: 350


probiwon.com


View Profile WWW
November 19, 2010, 09:07:52 PM
 #11

+1 on showing actual balances without rounding.

are you ready to see the numbers like this:

12.3234453404553525454656

?

In a system that can trade fractional offerings such numbers are always presented. Simple rounding on sending and receiving sides negate it to the fixed-precise and beautiful numbers.

By the way, btcex.com do not use the decimal rounding. We rounding to the smallest possible size of the quantum of currency. Usually it is 0.01 but not always, it can be exotic such as 0.001 or 0.025.

New bitcoin lottery: probiwon.com
- Может, ты ещё и в Невидимую Руку Рынка веруешь? - Зачем же веровать в то, что можно наблюдать непосредственно?
tcatm
Sr. Member
****
Offline Offline

Activity: 337


View Profile
November 19, 2010, 09:13:01 PM
 #12

you could limit all prices to 4..6 decimal places.
ribuck
Donator
Legendary
*
Offline Offline

Activity: 826


View Profile
November 19, 2010, 09:13:43 PM
 #13

are you ready to see the numbers like this:

12.3234453404553525454656

No. MtGox already calculates the transactions to a certain level of precision (I think it might be 4). All we want is for our real MtGox balance to be exposed through the interface.

Without that, we can't withdraw our entire balance. If it says 80 bitcoins, but rejects our request to withdraw 80 bitcoins, how are we to know that we really need to ask for 79.9775?
tcatm
Sr. Member
****
Offline Offline

Activity: 337


View Profile
November 19, 2010, 09:18:45 PM
 #14

Without that, we can't withdraw our entire balance. If it says 80 bitcoins, but rejects our request to withdraw 80 bitcoins, how are we to know that we really need to ask for 79.9775?

Click on "Account History".
bitcoinex
Sr. Member
****
Offline Offline

Activity: 350


probiwon.com


View Profile WWW
November 19, 2010, 09:19:45 PM
 #15

are you ready to see the numbers like this:

12.3234453404553525454656

No. MtGox already calculates the transactions to a certain level of precision (I think it might be 4).

It's awful. On the set of small transactions rounding error can reach substantial quantities! Trading robots resent!

New bitcoin lottery: probiwon.com
- Может, ты ещё и в Невидимую Руку Рынка веруешь? - Зачем же веровать в то, что можно наблюдать непосредственно?
ribuck
Donator
Legendary
*
Offline Offline

Activity: 826


View Profile
November 19, 2010, 10:46:05 PM
 #16

Click on "Account History".
Thanks! I see three decimal places for all the calculated values.
ShadowOfHarbringer
Legendary
*
Offline Offline

Activity: 1470


Bringing Legendary Har® to you since 1952


View Profile
November 20, 2010, 03:51:29 PM
 #17

Also *never* use float column sql data types, when storing money values decimal is the way to go.

Precisely, i believe that in PHP it may be best to store floats as pure strings, and convert them when necessary. There were some nasty bugs in float-to-float comparisons in PHP, i don't remember if they fixed them all.

You have it wrong, floats are not supposed to be used to store exact values, decimal types are designed for that purpose


No, you have it wrong, because You are talking about databases, not PHP. PHP does not have something like "decimal types" as far as i know.

But PHP has the strings, which can store almost anything with any precision you need.

ShadowOfHarbringer
Legendary
*
Offline Offline

Activity: 1470


Bringing Legendary Har® to you since 1952


View Profile
November 20, 2010, 03:54:07 PM
 #18

+1 on showing actual balances without rounding.

+1 on pre-calculating the fee that would be charged, and showing it to the user to see before submitting an order.

It's awful. On the set of small transactions rounding error can reach substantial quantities! Trading robots resent!

I agree with all of these suggestions.
Trading should be done with (almost ?) absolute rounding precision, if possible.

The Madhatter
Hero Member
*****
Offline Offline

Activity: 490


My avatar pic says it all


View Profile
November 20, 2010, 04:25:42 PM
 #19

PHP's float precision can be adjusted in the php.ini file too.
wumpus
Hero Member
*****
Offline Offline

Activity: 798

No Maps for These Territories


View Profile
November 20, 2010, 04:39:11 PM
 #20

Financial programming lesson one: never use floats for money!

If there is no built-in fixed-point decimal type in your language it's best to use large integers.... or indeed, strings, although that makes computation somewhat harder.

Bitcoin Core developer [PGP] Warning: For most, coin loss is a larger risk than coin theft. A disk can die any time. Regularly back up your wallet through FileBackup Wallet to an external storage or the (encrypted!) cloud. Use a separate offline wallet for storing larger amounts.
Pages: [1] 2 3 »  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!