Subject | Re: [firebird-support] Re: The integer part of a number |
---|---|
Author | Alexandre Benson Smith |
Post date | 2006-11-24T04:40:11Z |
Adam wrote:
I will answer that the cast to integer should do what he was after.
But when I was replying I saw he wants just the integer part besides
rounding, then I will suggest an UDF.
When I saw your answer I tried again (as you said it will be SQL
Standard behaviour)
But if you are right then FB is not standard complaint in this aspect.
SQL> select cast(1.9 as integer) from rdb$database;
CAST
============
2
SQL>
see you !
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br
> --- In firebird-support@yahoogroups.com, news@... wrote:Adam,
>
>> Hi,
>>
>> I am looking for a way to get the integer part of
>> a number in a stored procedure.
>>
>> Example:
>> There is a given number, eg. 1.997260274.
>> In this case, I want to have "1" returned.
>>
>> I thought this was a trivial problem, but I have no
>> clue how to solve this with Firebird 1.5.
>>
>
> The SQL standard defines that when casting between a numeric and an
> integer the value should round down.
>
> So
>
> cast(SomeNumeric as Integer)
>
> should return exactly what you want.
>
> Adam
>
I will answer that the cast to integer should do what he was after.
But when I was replying I saw he wants just the integer part besides
rounding, then I will suggest an UDF.
When I saw your answer I tried again (as you said it will be SQL
Standard behaviour)
But if you are right then FB is not standard complaint in this aspect.
SQL> select cast(1.9 as integer) from rdb$database;
CAST
============
2
SQL>
see you !
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br