Garbage Value on Multiply

Garbage Value on Multiply

Postby shri_fwh » Sat Apr 20, 2019 6: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: Select all  Expand view


#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 19.12, BCC 7 32 bit, MariaDB
shri_fwh
 
Posts: 301
Joined: Mon Dec 07, 2009 2:49 pm

Re: Garbage Value on Multiply

Postby Otto » Sat Apr 20, 2019 10:53 pm

Helli Shridhar,
I use xharbour and for me it is working fine.
Best regards
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: Garbage Value on Multiply

Postby shri_fwh » Sun Apr 21, 2019 8: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
Last edited by shri_fwh on Sun Apr 21, 2019 8:52 am, edited 1 time in total.
Thanks
Shridhar
FWH 19.12, BCC 7 32 bit, MariaDB
shri_fwh
 
Posts: 301
Joined: Mon Dec 07, 2009 2:49 pm

Re: Garbage Value on Multiply

Postby Marc Vanzegbroeck » 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
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Garbage Value on Multiply

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Garbage Value on Multiply

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Garbage Value on Multiply

Postby nageswaragunupudi » Mon May 27, 2019 4:27 pm

Here is a workaround, not a fix.

Please convert
Code: Select all  Expand view

nAmt := ( nRate *  nQty )
 


as
Code: Select all  Expand view

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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 45 guests

cron