SET FIXED

Projeto [x]Harbour - Compilador de código aberto compatível com o Clipper.

Moderador: Moderadores

Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

SET FIXED

Mensagem 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
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

SET FIXED

Mensagem por JoséQuintas »

Alguém que tenha Clipper pode testar aonde isso causa diferença?

No momento só máquina com W10 64 bits.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

SET FIXED

Mensagem 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.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 7928
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 1 vez

SET FIXED

Mensagem 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.
Saudações,
Itamar M. Lins Jr.
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

SET FIXED

Mensagem por JoséQuintas »

Então... SET FIXED não serve pra m. nenhuma.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

SET FIXED

Mensagem por JoséQuintas »

no harbour-users mostraram uma alternativa boa hb_NToC()

? hb_NToC( 1 / 3 )
0.3333333333333333

? hb_NToC( 1.00000000000 )
1
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

SET FIXED

Mensagem 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...
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

SET FIXED

Mensagem 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
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 7928
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 1 vez

SET FIXED

Mensagem 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.
Saudações,
Itamar M. Lins Jr.
alxsts
Colaborador
Colaborador
Mensagens: 3092
Registrado em: 12 Ago 2008 15:50
Localização: São Paulo-SP-Brasil

SET FIXED

Mensagem 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.
[]´s
Alexandre Santos (AlxSts)
Avatar do usuário
asimoes
Colaborador
Colaborador
Mensagens: 4919
Registrado em: 26 Abr 2007 16:48
Localização: RIO DE JANEIRO-RJ

SET FIXED

Mensagem por asimoes »

SET DECIMALS TO 15, funciona retorna 0.333333333333333
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Responder