Subject | RE: [firebird-support] How to CAST float to integer with error? |
---|---|
Author | Svein Erling Tysvær |
Post date | 2015-05-26T07:24:43Z |
>Hello,Not quite what you're asking for, Bruce, but
>is it possible by using CAST or in any other way to get database error when casting such number to integer?
>SELECT CAST('13.245' AS INTEGER) FROM RDB$DATABASE
>This gives 13 but instead I would like to get an error because precision is lost.
>
>However, I would like to NOT get an error when doing this:
>SELECT CAST('13.000' AS INTEGER) FROM RDB$DATABASE
>Becasue here precision is not lost.
>
>Is it possible to obtain such behaviour in easy way or do I have to use regular expressions?
SELECT CAST(13.245 AS INTEGER) FROM RDB$DATABASE
WHERE CAST(13.245 AS INTEGER) * 1000 = cast(13.245 * 1000 as Integer)
does return any rows, whereas this statement does:
SELECT CAST(13.000 AS INTEGER) FROM RDB$DATABASE
WHERE CAST(13.000 AS INTEGER) * 1000 = cast(13.000 * 1000 as Integer)
HTH,
Set