Re: getXXX methods
| От | Oliver Jowett |
|---|---|
| Тема | Re: getXXX methods |
| Дата | |
| Msg-id | 40EF0F10.9040409@opencloud.com обсуждение исходный текст |
| Ответ на | Re: getXXX methods (Dave Cramer <pg@fastcrypt.com>) |
| Список | pgsql-jdbc |
Dave Cramer wrote: > Well, I have an interesting problem... > > Detecting that a value is greater than MaxLong? > > If I parse it using Double.parseDouble, and it is greater than LongMax > by 1 or so, the value ends up actually being less due to rounding ? > > Any suggestions? The problem is that you're going via a double, you're going to lose precision there regardless of what you do (you don't have 64 bits of mantissa+sign to play with). If you want to retain precision, don't use a double as your intermediate value. Perhaps extract everything before the first '.' and use parseLong? That will truncate rather than round the value though. I don't like the whole idea of silently losing data anyway.. -O
В списке pgsql-jdbc по дате отправления: