[firebase-br] Arredondamento/Truncamento Firebrid

Rafa Pimenta rafa.spimenta em gmail.com
Qui Maio 12 16:06:49 -03 2011


Infelizmente vou ter que usar a outra, aqui na empresa a versão do delphi é
1.5.. =/
Mas sem dúvida que é uma ótima dica!
Obrigado.

2011/5/12 Paulo Portella <pportellaa.firebase em gmail.com>

> http://www.firebirdsql.org/refdocs/langrefupd21-intfunc-trunc.html
>
>
>   TRUNC()
>
> Available in: DSQL, PSQL
>
> Added in: 2.1
>
> Description: Returns the integer part of a number. With the optional
> /|scale|/ argument, the number can be truncated to powers-of-ten multiples
> (tens, hundreds, tenths, hundredths, etc.) instead of just integers.
>
> Result type: INTEGER, (scaled) BIGINT or DOUBLE
>
> Syntax:
>
>   TRUNC (/|<number>|/  [,/|<scale>|/])
>
>   /|<number>|/   ::=  a numerical expression
>   /|<scale>|/    ::=  an integer specifying the number of decimal places
>                   toward which should be truncated, e.g.:
>                      2 for truncating to a multiple of 0.01
>                      1 for truncating to a multiple of 0.1
>                      0 for truncating to a whole number
>                     -1 for truncating to a multiple of 10
>                     -2 for truncating to a multiple of 100
>
> Notes:
>
>   *
>
>     If the /|scale|/ argument is present, the result usually has the
>     same scale as the first argument, e.g.
>
>         o
>
>           TRUNC(789.2225, 2) returns 789.2200 (not 789.22)
>
>         o
>
>           TRUNC(345.4, -2) returns 300.0 (not 300)
>
>         o
>
>           TRUNC(-163.41, 0) returns -163.00 (not -163)
>
>     Otherwise, the result scale is 0:
>
>         o
>
>           TRUNC(-163.41) returns -163
>
>
>     Important
>
> If you are used to the behaviour of the external function |TRUNCATE|,
> please notice that the /internal/ function TRUNC always truncates toward
> zero, i.e. upward for negative numbers.
>
>
> Vida de americano é assim: iPhone, iPod, iPad, iMac....
> Já a de brasileiro é assim:IPTU, IPVA, ICMS, IPI etc
>
>
>
> Em 12/05/2011 12:15, Rafa Pimenta escreveu:
>
>> Boa tarde a todos,
>>
>> Estou precisando truncar um valor que está com 3 casas decimais de forma
>> que
>> ele só fique com a parte inteira no firebrid.
>> Observei que o cast arredonda o valor, como faço para truncá-lo?
>>
>> Exemplo usando cast:
>>
>> valor 1,99
>> resultadot: 2
>>
>> Exemplo que eu preciso:
>> valor 1,99
>> resultado: 1
>>
>> Obrigado.
>>
>>  ______________________________________________
> FireBase-BR (www.firebase.com.br) - Hospedado em www.locador.com.br
> Para saber como gerenciar/excluir seu cadastro na lista, use:
> http://www.firebase.com.br/fb/artigo.php?id=1107
> Para consultar mensagens antigas: http://firebase.com.br/pesquisa
>



-- 
*Rafael Pimenta
Meu Blog: http://delphiexpresso.blogspot.com/*



Mais detalhes sobre a lista de discussão lista