Bitcoin Forum
December 10, 2016, 03:28:48 AM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Cheaper In Bitcoins | Explaination of the 0.01 Bitcent anomoly  (Read 1281 times)
Xenland
Legendary
*
Offline Offline

Activity: 980


I'm not just any shaman, I'm a Sha256man


View Profile
November 04, 2011, 12:00:11 PM
 #1

Just for the record, I realize that some product pages(usually that include shipping, tax, or sometimes additional options) might come out to 0.01 Bitcent more then what they should looking at initial values; I assure you this is not me trying to swipe 0.01BTC per order, no there is need for that and I assure you this is not a math miscalculation issue either. In fact this is a "rounding anomaly". my websites back-end processes transaction prices using USD units which would cause some rounding anomalies with the decimal limit in comparisons to Bitcoins 8 decimal precision.

Hope this makes sense to anybody whom was wondering about such issues like this......
Thanks
1481340528
Hero Member
*
Offline Offline

Posts: 1481340528

View Profile Personal Message (Offline)

Ignore
1481340528
Reply with quote  #2

1481340528
Report to moderator
1481340528
Hero Member
*
Offline Offline

Posts: 1481340528

View Profile Personal Message (Offline)

Ignore
1481340528
Reply with quote  #2

1481340528
Report to moderator
Bitcoin addresses contain a checksum, so it is very unlikely that mistyping an address will cause you to lose money.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481340528
Hero Member
*
Offline Offline

Posts: 1481340528

View Profile Personal Message (Offline)

Ignore
1481340528
Reply with quote  #2

1481340528
Report to moderator
1481340528
Hero Member
*
Offline Offline

Posts: 1481340528

View Profile Personal Message (Offline)

Ignore
1481340528
Reply with quote  #2

1481340528
Report to moderator
1481340528
Hero Member
*
Offline Offline

Posts: 1481340528

View Profile Personal Message (Offline)

Ignore
1481340528
Reply with quote  #2

1481340528
Report to moderator
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218


Gerald Davis


View Profile
November 05, 2011, 03:50:15 AM
 #2

People actually get worried when converted prices are off by 0.01 BTC = 3 pennies?

Xenland
Legendary
*
Offline Offline

Activity: 980


I'm not just any shaman, I'm a Sha256man


View Profile
November 05, 2011, 08:59:50 AM
 #3

Youd be suprised from the other rediculas requests and odd messages i get.... Somedays its entertaining other days its hard to stay professional when your constantly wondering if the person your talking to will start spouting off random sayings. Its comes with running a biz.... I suppose....
genjix
Legendary
*
Offline Offline

Activity: 1232


View Profile
November 05, 2011, 12:48:06 PM
 #4

It is because you are using floating point numbers.

There are a number of different ways to fix it if you're using PHP.

https://bitcointalk.org/index.php?topic=4086.0
Xenland
Legendary
*
Offline Offline

Activity: 980


I'm not just any shaman, I'm a Sha256man


View Profile
November 05, 2011, 09:57:20 PM
 #5

Thanks for the input but I'm very aware of floating point precision flaws and I think it more has to do with rounding Bitcoins' 8 decimals and compressing them into a common format for everyone which is usually 2 decimals(also aimed at USA so I picked the 2 decimal precision)

Also on top of that all my prices are linked to USD costs not BTC so they are converted on the fly for each display for example

Product "A" costs around $250 so to show the customer the price in BTC value I gotta divide which at the current rate $3.1
Quote
$250/$3.1 = 80.645161290323 BTC
(12 decimal precision)

Obviously displaying a 12 decimal precision number will look un-attractive to buyers so I compress it to a common format of 2 decimal places which PHP outputs as
Quote
80.65


How ever a "sub-total" is never the "total" cost I have to include shippingcosts and once in a while "tax" so lets look at this example (remember my prices in my database are link in USD format)
Quote
Subtotal: $250/$3.1 = 80.645161290323 BTC
Shipping: $20/$3.1 = 6.4516129032258

Quote
Subtotal + shipping = $270
Subtotal + shipping = 87.096774193549 BTC


Check
Quote
87.096774193549 BTC * $3.1 = 270;
$270 / $3.1 = 87.096774193548 BTC


Compare Values
Quote
87.096774193549
87.096774193548


Round 87.096774193548 BTC
Quote
87.1 BTC


Notice the extra Bitcent?
even though customers are Paying the same thing as they would be.... it just "looks" more.
Xenland
Legendary
*
Offline Offline

Activity: 980


I'm not just any shaman, I'm a Sha256man


View Profile
November 05, 2011, 10:02:29 PM
 #6

I just noticed that PHP will correctly round my example to 87.1 BTC along with the other one... however this was just an example of what I have found I can't find which product is showing these anomalies to use correct values for the example.. but basically my example should show you wants going on...
genjix
Legendary
*
Offline Offline

Activity: 1232


View Profile
November 05, 2011, 10:04:46 PM
 #7

I just noticed that PHP will correctly round my example to 87.1 BTC along with the other one... however this was just an example of what I have found I can't find which product is showing these anomalies to use correct values for the example.. but basically my example should show you wants going on...

If you want to clip decimals, a good method to use is:

$foo = "8.91232323234223";
echo bcadd($foo, '0', 5);  // truncates to 5 decimal places

hope that helps.

Also, you should *always* round down and absorb the cost yourself.
Xenland
Legendary
*
Offline Offline

Activity: 980


I'm not just any shaman, I'm a Sha256man


View Profile
November 05, 2011, 11:46:23 PM
 #8

I just noticed that PHP will correctly round my example to 87.1 BTC along with the other one... however this was just an example of what I have found I can't find which product is showing these anomalies to use correct values for the example.. but basically my example should show you wants going on...

If you want to clip decimals, a good method to use is:

$foo = "8.91232323234223";
echo bcadd($foo, '0', 5);  // truncates to 5 decimal places

hope that helps.

Also, you should *always* round down and absorb the cost yourself.

Well there is technically "no cost" |  transactions ultimately do math in USD format then convert to BTC for the total cost to prevent any possible problems with floats that I'm not aware of its just when you compare it to the invoice it looks like things don't add up.

Thanks for suggesting the bcadd() I'll look into that and see if it helps
Pages: [1]
  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!