Bitcoin Forum
June 20, 2018, 02:39:17 AM
 News: Latest stable version of Bitcoin Core: 0.16.1  [Torrent]. (New!)
 Home Help Search Donate Login Register
 Pages: 1 [2]  All
 Author Topic: Stop using floating point!  (Read 28105 times)
racerguy
Sr. Member

Offline

Activity: 270
Merit: 250

 February 13, 2012, 03:07:33 AM

Thanks I've been waiting over 7months to click that link.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1529462357
Hero Member

Offline

Posts: 1529462357

Ignore
 1529462357

1529462357
 Report to moderator
grue
Global Moderator
Legendary

Offline

Activity: 2100
Merit: 1138

 February 13, 2012, 03:28:59 AM

From what i can tell, bitcoinhelper (lol @ "helper") is just randomly quoting pieces of code and ranting about how we shouldn't use floats for everything. but for some reason, he didn't realize that floats are only used in GUI related stuff.

something tells me that he is either a kid who gets really hyped up about small issues (looks like he made an account just to post this topic ), or a troll.

and he's a necro

It is pitch black. You are likely to be eaten by a grue.

genjix
Legendary

Offline

Activity: 1232
Merit: 1000

 February 13, 2012, 04:29:54 PM

I think bitcoin using floats/doubles is frankly stupid.

https://bitcointalk.org/index.php?topic=4086.0
http://bitcoinmedia.com/merchant-developer-tutorial/
Steve
Hero Member

Offline

Activity: 868
Merit: 1000

 February 17, 2012, 04:50:48 AM

This debate is silly.  If you're really a purist, forget scaled decimal and use integers and fractions.  Smalltalk was invented in the 70's and by default, it preserves the original representation of numbers...  "1 / 2" yields a fraction with the integer 1 as the numerator and 2 as the denominator.  Multitply it by 3 and you get another fraction, "3 / 2".  Multiply that by 2 and you get the integer "3" (yes, it reduces fractions).  You don't get better precision than that.  A 64bit floating point number has plenty of precision to deal with anything bitcoin needs…try "21000000.00000002 / 2" …it works.  When working with floating point within its bounds of precision, you only need to know enough about math to know when it's appropriate to round.

(gasteve on IRC) Does your website accept cash? https://bitpay.com
2112
Legendary

Offline

Activity: 2114
Merit: 1027

 February 17, 2012, 06:44:10 PM

This thread is very sad. Bitcoin is seriously affected with not-invented-here-itis. I personally started to think that the current milieu here is hopeless. The only hope is that the currently involved software designers fall of the face of the Earth's Internet and get replaced by a new blood.

On the other hand I also know that a lot of bright young people read this forum. So for the benefit of the young blood:

1) please learn the difference between binary floating point and decimal floating point. The good starting point is: http://speleotrove.com/decimal/

2) please compile this little C program using your recent C compiler:
Code:
#include <stdio.h>
int main()
{
_Decimal32 x,y;

x = 1.df;
x /= 10.df;
y = x;
y *= 10.df;
printf("%Hf %Hf\n",x,y);
return 0;
}
For example: "gcc d.c -ldfp". If you get "library not found for -ldfp" error, then read the following and complain to your software vendor.

3) You became a collateral damage in the mortal combat between IBM and Intel. They are both pushing two incompatible implementations of decimal floating point: IBM's DPD (densely packed decimal) and Intel's BID (binary integer decimal). The libdfp code is out there on the Internet, you'll need to search for it in places that aren't easily accessible to lawyers of the two concerns that I named above.

Please comment, critique, criticize or ridicule BIP 2112: https://bitcointalk.org/index.php?topic=54382.0
Long-term mining prognosis: https://bitcointalk.org/index.php?topic=91101.0
 Pages: 1 [2]  All
 « previous topic next topic »