FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Garbage Value on Multiply
Posts: 336
Joined: Mon Dec 07, 2009 02:49 PM
Garbage Value on Multiply
Posted: Sat Apr 20, 2019 06:43 PM
Dear All ,

Today I am facing very strange issue on the multiply function. It is NOT working properly for some numbers as given below examples.

1. 597.67 * 100 = Not Working shows **********
2. 597.67 * 1000 = Working

Could you please help me on this its very strange and weird experience for me. I would request to you all to help to me on this.

Code (fw): Select all Collapse
#include "Fivewin.ch"

function main
  local oDlg
  local oFont
  local nRate := 597.67
  local nQTy := 100
  local nAmt := ( nRate *  nQTy )
  local aoGET := Array(5)

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 900,700 PIXEL TRUEPIXEL FONT oFont

   @100,20 SAY "Rate"  PIXEL
   @100,70  GET aoGET[ 1 ] VAR nRate PICTURE "@Z 99,99,99,999.99" SIZE 100 , 20 OF oDlg PIXEL

   aoGET[ 1 ]:bValid := < ||

                          nAmt := ( nRate *  nQTy )
                          oDlg:Update()

                          return .t.

                        >

   @100,180 SAY "Qty"  PIXEL
   @100,230 GET aoGET[ 2 ] VAR nQTy PICTURE "@Z 99,99,99,999" SIZE 100 , 20 OF oDlg PIXEL

   aoGET[ 2 ]:bValid := < ||

                          nAmt := ( nRate *  nQTy )
                          oDlg:Update()

                          return .t.

                        >



   @100,360 SAY "Amount"  PIXEL
   @100,450 GET aoGET[ 3 ] VAR nAmt PICTURE "@Z 99,99,99,99,999.99" SIZE 200 , 20 OF oDlg PIXEL UPDATE

   ACTIVATE DIALOG oDlg


return nil
Thanks

Shridhar

FWH 24.04, BCC 7 32 bit, MariaDB
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Garbage Value on Multiply
Posted: Sat Apr 20, 2019 10:53 PM

Helli Shridhar,
I use xharbour and for me it is working fine.
Best regards
Otto

Posts: 336
Joined: Mon Dec 07, 2009 02:49 PM
Re: Garbage Value on Multiply
Posted: Sun Apr 21, 2019 08:15 AM
Dear Otto ,

Also the .EXE working is stopped due to Multiply (arithmetic) Issue. I have posted another Topic as "OS Error the .EXE is NOT responding"


I am using FWH/Harbour 64bit Version.



Thanks
Shridhar
Thanks

Shridhar

FWH 24.04, BCC 7 32 bit, MariaDB
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Garbage Value on Multiply
Posted: Sun Apr 21, 2019 11:29 AM

Hi,

I can confirm that I also get the '***.' with Harbour FWH 64bit.
Also with 50 and 1500
The EXE is not stopped

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Garbage Value on Multiply
Posted: Sun Apr 21, 2019 11:35 AM

I too observed the same problem with Harbour64 and bcc64.
Harbour64 with MSVC and all 32bits are working correctly.

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Garbage Value on Multiply
Posted: Mon Apr 22, 2019 10:25 AM

The error happens without using FWH

It seems a Harbour bug using bcc7 64 bits in source\harbour\vm\itemapi.c

/ converts a numeric to a string with optional width & precision. /

HB_BOOL hb_itemStrBuf( char * szResult, PHB_ITEM pNumber, int iSize, int iDec )

used from:

char * hb_itemStr( PHB_ITEM pNumber, PHB_ITEM pWidth, PHB_ITEM pDec )

It is not a simple code, so low level debugger may be required to compare behavior with MSVC and MinGW 64 bits.

MSVC and MinGW 64 bits both work fine.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Garbage Value on Multiply
Posted: Mon May 27, 2019 04:27 PM
Here is a workaround, not a fix.

Please convert
Code (fw): Select all Collapse
nAmt := ( nRate *  nQty )


as
Code (fw): Select all Collapse
nAmt := ROUND( nRate *  nQty, 2 )

in all the places in the program.

With this change, you can see the values of nAmt correctly
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion