sql - MySQL - Decimal(M,D) vs Double(M,D) -


well, know question has been asked several times.. but, still don't satisfied explanation, on why must use decimal monetary purpose.. far know,

  1. decimal can save larger number double
  2. decimal stores exact value , double store approx. value

so, can explain , maybe give actual result in query about,

  1. what mean exact value , approx. value?
  2. why should use decimal monetary purpose ?

currently i'm using double(15,2) gives enough precision boss. besides ran test in sqlfiddle , don't see precision issue..

tested query:

create table test(   value1 decimal(15,4),   value2 double(15,4)   );  insert test values(0.0001, 0.0001),                        (123.123, 123.123),                         (0.0000001, 0.0000001);  select sum(value1), sum(value2) test 

result

sum(value1) sum(value2) 123.1231    123.1231 


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -