KaozTiposta (OP)
|
|
June 25, 2015, 09:24:39 PM |
|
Hello
I am developing a bitcoin application using Mysql.
What is the best way to store it? DECIMAL(16,8) or multiplying it with 100M?
|
|
|
|
secrethedgehog
Newbie
Offline
Activity: 50
Merit: 0
|
|
June 25, 2015, 09:39:05 PM |
|
A few clients I have worked with store it as VARCHAR, I am no expert but I don't believe that VARCHAR is correct way to store a decimal number.
Personally I would store it as Satoshi BIGINT and then multiply using the language that pulls the data out.
|
|
|
|
KaozTiposta (OP)
|
|
June 25, 2015, 09:41:30 PM |
|
I'm so lazy to multiply/divide it everywhere.. Also VARCHAR sounds interesting to me.
So I think I will go with DECIMAL but this is a little sensitive project and I don't want to see round errors. Can DECIMAL has rounding errors ?
|
|
|
|
secrethedgehog
Newbie
Offline
Activity: 50
Merit: 0
|
|
June 25, 2015, 09:51:00 PM |
|
What language are you using to pull the data? I usually just create one function to multiply and format. Then I can just use that on whatever needs it. I don't ever use Decimal in MySQL so I don't really know to be honest. I was only using VARCHAR as a bad example. I wouldn't suggest this. It has caused me some problems in the past. http://stackoverflow.com/questions/3008371/storing-numbers-as-varchar
|
|
|
|
person
|
|
June 25, 2015, 09:56:41 PM |
|
Store as satoshis: BIGINT Manipulate as satoshis
Then you can convert in any type (BTC, mBTC) based on user preference only for display.
|
|
|
|
aysha9859
Member
Offline
Activity: 93
Merit: 10
Srry 4 my bad English
|
|
June 26, 2015, 09:53:24 AM |
|
Store as satoshis: BIGINT Manipulate as satoshis
Then you can convert in any type (BTC, mBTC) based on user preference only for display.
im using BIGINT on my faucet project. you can play however you want with satoshi. but sometimes im getting errors. for ex: i have 50000 in the cell. divide 100000000 i get output like 0.00049999 for solve this error im writing convert function. im still working on it.
|
|
|
|
bitnanigans
|
|
June 26, 2015, 12:57:27 PM |
|
You can use either DECIMAL(16,8) or BIGINT. If you're storing with BIGINT, you will have to make sure that you convert your values correctly at all times, or you may run into several problems. The decimal is used for precision math, so you won't encounter rounding errors with the data type.
|
|
|
|
person
|
|
June 26, 2015, 02:35:56 PM |
|
Store as satoshis: BIGINT Manipulate as satoshis
Then you can convert in any type (BTC, mBTC) based on user preference only for display.
im using BIGINT on my faucet project. you can play however you want with satoshi. but sometimes im getting errors. for ex: i have 50000 in the cell. divide 100000000 i get output like 0.00049999 for solve this error im writing convert function. im still working on it. For display, why divide if you can just add the . after 8 characters (as string)?
|
|
|
|
wh00per
|
|
June 27, 2015, 05:59:55 PM |
|
What's wrong with double? The precison is way better than what you need for satoshi transactions. https://dev.mysql.com/doc/refman/5.0/en/fixed-point-types.htmlYou can also do BIGINT as satoshi, or varchar, however while bigint indexes nicely and it's quick, varchar is a little laggy. As of 5.0.6, MySQL performs DECIMAL (or NUMERIC) operations with a precision of 65 decimal digits. If you need exact values in your applications I'd rather use one of those two.
|
CSA/cUL Certified Power Distribution Panels - Basic, Switched, Metered. 1-3 phases. Up to 600V. NMC:N4F9qvHz11BHcc4nh1LCJFsrZhA1EWgVwj
|
|
|
Vortex20000
|
|
June 28, 2015, 02:11:12 PM |
|
Just use MySQL's double type, it's what I use and I've had any problems with it thus far.
|
|
|
|
|
THE TRADER
Newbie
Offline
Activity: 16
Merit: 0
|
|
June 28, 2015, 03:06:50 PM |
|
Be Carefull ob un Mysql Injections. https://de.wikipedia.org/wiki/SQL-InjectionIt`s maybe not actually the Securityst Technologie. Scrypt.cc got hacked by mysql injection. And used a got based on mysql/ddos page so far. My opion but im not a Profi
|
|
|
|
secrethedgehog
Newbie
Offline
Activity: 50
Merit: 0
|
|
June 28, 2015, 04:26:21 PM |
|
Be Carefull ob un Mysql Injections. https://de.wikipedia.org/wiki/SQL-InjectionIt`s maybe not actually the Securityst Technologie. Scrypt.cc got hacked by mysql injection. And used a got based on mysql/ddos page so far. My opion but im not a Profi There are many techniques to stop this, You shouldn't be scared of using MySql, You should be scared of how good your coding is.... or not. In PHP there are techniques like Prepared Statements and escaping characters.
|
|
|
|
noel57
|
|
June 29, 2015, 05:31:51 AM |
|
Hello
I am developing a bitcoin application using Mysql.
What is the best way to store it? DECIMAL(16,8) or multiplying it with 100M?
Keep it simply simple, 8 digits still remain the best, any other extension will be boring and some-how confusing.
|
|
|
|
|