Página 1 de 1
SET FIXED
Enviado: 26 Fev 2020 13:07
por JoséQuintas
Descobri uma nova mas.... parece que não funciona.
SET FIXED ON
? 1 / 3
0.33
SET FIXED OFF
? 1 / 3
0.33
SET FIXED
Enviado: 26 Fev 2020 14:38
por JoséQuintas
Alguém que tenha Clipper pode testar aonde isso causa diferença?
No momento só máquina com W10 64 bits.
SET FIXED
Enviado: 26 Fev 2020 14:42
por JoséQuintas
Só acrésimo:
Porque considero isso importante?
Porque se pego um valor do MySQL como 1.33333333, vém 1.33
Quero ver se SET FIXED OFF resolveria meu problema.
Se no Clipper funcionar.... então o Harbour deveria fazer igual.
Por enquanto, me parece que SET FIXED não serve pra nada, o que seria estranho existir uma função pra nada.
SET FIXED
Enviado: 26 Fev 2020 14:48
por Itamar M. Lins Jr.
Ola!
Elementar meu caro!
Esqueceu do "Set Decimals to 8" ?
Código: Selecionar todos
function main
set fixed off
set decimals to 8
cls
? 1/3 //0.33333333
Saudações,
Itamar M. Lins Jr.
SET FIXED
Enviado: 26 Fev 2020 16:09
por JoséQuintas
Então... SET FIXED não serve pra m. nenhuma.
SET FIXED
Enviado: 26 Fev 2020 16:37
por JoséQuintas
no harbour-users mostraram uma alternativa boa hb_NToC()
? hb_NToC( 1 / 3 )
0.3333333333333333
? hb_NToC( 1.00000000000 )
1
SET FIXED
Enviado: 26 Fev 2020 16:42
por JoséQuintas
SET DECIMALS TO 2
SET FIXED ON
? Val( hb_NTOC( 1 / 3 ) )
? Val( hb_NTOC( 1.000000000000000 ) )
SET FIXED OFF
? Val( hb_NTOC( 1 / 3 ) )
? Val( hb_NTOC( 1.000000000000000 ) )
Mesmo resultado anterior, tanto faz o SET FIXED ou SET DECIMALS.
Vai entender pra que serve o SET FIXED...
SET FIXED
Enviado: 26 Fev 2020 16:51
por JoséQuintas
Infelizmente a mesma bost.....
x := 1 / 3
? x
? hb_NTos( x )
? Val( hb_NTos( x ) )
? Val( hb_NTos( x ) ) / 1.0000000000000000000
Se colocar variável Harbour no meio, tudo retorna 0.33
SET FIXED
Enviado: 26 Fev 2020 17:29
por Itamar M. Lins Jr.
Ola!
Cê viu lá que a precisão do harbour é de 15 decimais!
Se o campo é float, flutuante, o set fixed não faz nada, só mostra o que set decimals mandou, não faz nada mesmo.
Faltou o set deci to 15
Código: Selecionar todos
function Main()
set deci to 15
x := 1 / 3
? x
? hb_NTos( x )
? Val( hb_NTos( x ) )
? hb_NTos( x / 1.0000000000000000000)
Saudações,
Itamar M. Lins Jr.
SET FIXED
Enviado: 26 Fev 2020 18:28
por alxsts
Olá!
O efeito é apenas na forma de exibição dos valores:
SET FIXED
Toggle fixing of the number of decimal digits displayed
------------------------------------------------------------------------------
Syntax
SET FIXED on | OFF | <xlToggle>
Arguments
ON fixes the decimal places display at the number of digits
specified by SET DECIMALS.
OFF allows the operation or function to determine the number of
decimal places to display.
<xlToggle> is a logical expression that must be enclosed in
parentheses. A value of true (.T.) is the same as ON, and a value of
false (.F.) is the same as OFF.
Description
SET FIXED toggles control of the display of decimal digits by the
current DECIMALS setting. When FIXED is ON, display of all numeric
output is fixed at the DECIMALS setting (two places if the SET DECIMALS
default value is in effect). When FIXED is OFF, numeric output displays
according to the default rules for numeric display. These are described
in the "Basic Concepts" chapter of the Programming and Utilities Guide.
Note that SET FIXED and SET DECIMALS affect only the display format of
numeric values and not the actual numeric precision of calculations.
Files Library is CLIPPER.LIB.
SET FIXED
Enviado: 26 Fev 2020 19:03
por asimoes
SET DECIMALS TO 15, funciona retorna 0.333333333333333