Strange problems on decimals - dangerous bug !!

Re: Strange problems on decimals - dangerous bug !!

Postby Marco Turco » Mon Jan 19, 2015 3:33 pm

Tried your code but I always got error.

sambomb wrote:Change the name of the var, nTest_Decimals := 3

Code: Select all  Expand view  RUN

#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("")
 
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Strange problems on decimals - dangerous bug !!

Postby rhlawek » Mon Jan 19, 2015 4:14 pm

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
User avatar
rhlawek
 
Posts: 194
Joined: Sun Jul 22, 2012 7:01 pm

Re: Strange problems on decimals - dangerous bug !!

Postby sambomb » Mon Jan 19, 2015 7:13 pm

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 view  RUN

#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
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Strange problems on decimals - dangerous bug !!

Postby Marco Turco » Mon Jan 19, 2015 8:24 pm

For error I mean that msginfo(str(88.456,10,nTest_Decimals )) Always return 88
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Strange problems on decimals - dangerous bug !!

Postby sambomb » Tue Jan 20, 2015 10:37 am

Try this now...
I included Set Decimals 20, Set Exact On, extra debugs to trace the value of nTest_Decimals
Code: Select all  Expand view  RUN


#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("")
 
 
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Strange problems on decimals - dangerous bug !!

Postby Marco Turco » Tue Jan 20, 2015 6:52 pm

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
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Strange problems on decimals - dangerous bug !!

Postby hmpaquito » Tue Jan 20, 2015 9:00 pm

Marco,

Please try so:

Code: Select all  Expand view  RUN

...
nTest_Decimals :=oQry:aData[1,7]

nTest_Decimals := Val( Str(nTest_Decimals, 10))               //  <---- New
...
 


Regards
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Strange problems on decimals - dangerous bug !!

Postby James Bott » Thu Jan 29, 2015 12:00 am

Marco,

Did you ever find a solution?

It looks like hmpaquito's idea might work. Did you try it?
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 41 guests