Page 3 of 3
Re: Strange problems on decimals - dangerous bug !!
Posted: Mon Jan 19, 2015 3:33 pm
by Marco Turco
Tried your code but I always got error.
sambomb wrote:Change the name of the var, nTest_Decimals := 3
Code: Select all | Expand
#include "fivewin.ch"
procedure start()
Local nTest_Decimals := 3
oSQLite := TSQLiteServer():New( "test.sql" )
If oSQLite:lError
msgStop( "error" )
RETURN
EndIf
cQuery:="SELECT * from t_tables;"
oQry:=oSQLite:Query(cQuery)
nTest_Decimals :=oQry:aData[1,7]
oQry:End()
oSQLite:End()
msginfo(nTest_Decimals ) && return 3
msginfo(valtype(nTest_Decimals )) && return N
msginfo(str(88.456,10,3)) && return 88.456
msginfo(str(88.456,10,nTest_Decimals )) && RETURN 88 !!!
return
function gettemppath()
return("")
Re: Strange problems on decimals - dangerous bug !!
Posted: Mon Jan 19, 2015 4:14 pm
by rhlawek
I have an off topic question. Where did/does the TSQLiteServer() class come from? I've searched high and low and have not yet come across this.
Thanks in advance.
Robb
Re: Strange problems on decimals - dangerous bug !!
Posted: Mon Jan 19, 2015 7:13 pm
by sambomb
Marco Turco wrote:Tried your code but I always got error.
sambomb wrote:Change the name of the var, nTest_Decimals := 3
Code: Select all | Expand
#include "fivewin.ch"
procedure start()
Local nTest_Decimals := 3
oSQLite := TSQLiteServer():New( "test.sql" )
If oSQLite:lError
msgStop( "error" )
RETURN
EndIf
cQuery:="SELECT * from t_tables;"
oQry:=oSQLite:Query(cQuery)
nTest_Decimals :=oQry:aData[1,7]
oQry:End()
oSQLite:End()
msginfo(nTest_Decimals ) && return 3
msginfo(valtype(nTest_Decimals )) && return N
msginfo(str(88.456,10,3)) && return 88.456
msginfo(str(88.456,10,nTest_Decimals )) && RETURN 88 !!!
return
function gettemppath()
return("")
What error?
All I did is replace nDecimals by nTest_Decimals
Re: Strange problems on decimals - dangerous bug !!
Posted: Mon Jan 19, 2015 8:24 pm
by Marco Turco
For error I mean that msginfo(str(88.456,10,nTest_Decimals )) Always return 88
Re: Strange problems on decimals - dangerous bug !!
Posted: Tue Jan 20, 2015 10:37 am
by sambomb
Try this now...
I included Set Decimals 20, Set Exact On, extra debugs to trace the value of nTest_Decimals
Code: Select all | Expand
#include "fivewin.ch"
procedure start()
Local nTest_Decimals := 3, nBkpDecimals := -999
Set Decimals to 20
Set Exact on
oSQLite := TSQLiteServer():New( "test.sql" )
If oSQLite:lError
msgStop( "error" )
RETURN
EndIf
cQuery:="SELECT * from t_tables;"
oQry:=oSQLite:Query(cQuery)
nBkpDecimals := nTest_Decimals
nTest_Decimals :=oQry:aData[1,7]
If nTest_Decimals == nBkpDecimals
MsgInfo("Identical values")
else
MsgInfo("Compare decimals values")
If AllTrim(Str(nTest_Decimals,25,20)) != AllTrim(Str(nBkpDecimals,25,20))
MsgInfo(AllTrim(Str(nTest_Decimals,25,20)),"nTest")
MsgInfo(AllTrim(Str(nBkpDecimals,25,20)),"nBkp")
else
MsgInfo("Equal strings")
end
End
oQry:End()
oSQLite:End()
msginfo(nTest_Decimals )
msginfo(valtype(nTest_Decimals ))
msginfo(str(88.456,10,3)) && return 88.456
msginfo(str(88.456,10,nTest_Decimals )) && RETURN 88 !!!
return
function gettemppath()
return("")
Re: Strange problems on decimals - dangerous bug !!
Posted: Tue Jan 20, 2015 6:52 pm
by Marco Turco
Hi sambomb,
i did your test. Identical value but it return always 88.
You can download source and executable from
http://109.228.12.120/softwaredistribut ... /test3.zip
Re: Strange problems on decimals - dangerous bug !!
Posted: Tue Jan 20, 2015 9:00 pm
by hmpaquito
Marco,
Please try so:
Code: Select all | Expand
...
nTest_Decimals :=oQry:aData[1,7]
nTest_Decimals := Val( Str(nTest_Decimals, 10)) // <---- New
...
Regards
Re: Strange problems on decimals - dangerous bug !!
Posted: Thu Jan 29, 2015 12:00 am
by James Bott
Marco,
Did you ever find a solution?
It looks like hmpaquito's idea might work. Did you try it?