List: | General Discussion | « Previous MessageNext Message » | |

From: | Matt Loschert | Date: | April 12 2003 2:41pm |

Subject: | Re: rounding/truncation of decimal fields | ||

View as plain text |

Interesting. I had never seen this page of the manual before. However, you appear to be correct. I don't see an applicable reference there either. I think I am going to re-post my message to the bugs list since no one has shown me yet that this is definitely expected behavior. Thanks, - Matt On Fri, 11 Apr 2003, Doug Thompson wrote: > I don't see this reference mentioned anywhere in this thread: > > http://www.mysql.com/doc/en/Problems_with_float.html > > Doug > > > On Fri, 11 Apr 2003 15:36:45 -0400 (EDT), Matt Loschert wrote: > > >Exactly the point. I am not saying it is wrong. I am just wondering if > >it is supposed to operate this way. I would assume (possibly incorrectly) > >that a number supplied as a string would be transformed to numerical form > >by MySQL, then inserted into the database (and consequently rounded or > >truncated, I don't care which, I just want consistency) as is done when > >you insert a number as a number. > > > >On Fri, 11 Apr 2003, gerald_clark wrote: > > > >> Well, in one case he supplied a string, not a number. > >> It most likely was promoted to a float before is was saved. > >> > >> Jones, Clifton R [CC] wrote: > >> > >> >No, I think he was surprised to find mySQL rounded two identical values > >> >*differently*.. please read his posting for the results.... > >> > > >> > > >> > > >> > > >> >>-----Original Message----- > >> >>From: gerald_clark [mailto:gerald_clark@stripped] > >> >>Sent: Friday, April 11, 2003 9:33 AM > >> >>To: Matt Loschert > >> >>Cc: mysql@stripped> >> >>Subject: Re: rounding/truncation of decimal fields > >> >> > >> >> > >> >>Why do you find this surprising? > >> >>You defined the field to have 2 deciimal places.. > >> >> > >> >>Matt Loschert wrote: > >> >> > >> >> > >> >> > >> >>>I have quick question about rounding and/or truncation of a > >> >>> > >> >>> > >> >>decimal table > >> >> > >> >> > >> >>>field. I ran into this unexpectedly and found it surprising. > >> >>> > >> >>>Given the following input: > >> >>> > >> >>> > >> >>> DROP TABLE IF EXISTS test1; > >> >>> CREATE TABLE test1 (id tinyint, truncated decimal(12,2)); > >> >>> INSERT INTO test1 VALUES (1, '0.004'); > >> >>> INSERT INTO test1 VALUES (2, 0.004 ); > >> >>> INSERT INTO test1 VALUES (3, '0.005'); > >> >>> INSERT INTO test1 VALUES (4, 0.005 ); > >> >>> SELECT * FROM test1; > >> >>> SELECT VERSION(); > > > >- Matt > > > >-- > >Matt Loschert - Software Engineer | email: loschert@stripped| > >ServInt Internet Services | web: http://www.servint.net/ | > >McLean, Virginia USA | phone: (703) 847-1381 |

Thread | ||
---|---|---|

• rounding/truncation of decimal fields | Matt Loschert | 10 Apr |

• Re: rounding/truncation of decimal fields | gerald_clark | 11 Apr |

• RE: rounding/truncation of decimal fields | Clifton R [CC] Jones | 11 Apr |

• Re: rounding/truncation of decimal fields | gerald_clark | 11 Apr |

• Re: rounding/truncation of decimal fields | Matt Loschert | 11 Apr |

• Re: rounding/truncation of decimal fields | Doug Thompson | 11 Apr |

• Re: rounding/truncation of decimal fields | Matt Loschert | 12 Apr |

• Re: rounding/truncation of decimal fields | Doug Thompson | 12 Apr |

• More on enum | Martin Gainty | 12 Apr |

• Re: rounding/truncation of decimal fields | Matt Loschert | 13 Apr |

• Re: rounding/truncation of decimal fields | Doug Thompson | 13 Apr |

• Re: rounding/truncation of decimal fields | Dan Nelson | 13 Apr |

• Re: rounding/truncation of decimal fields | Matt Loschert | 14 Apr |

• Re: rounding/truncation of decimal fields | Moon796 | 11 Apr |