FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour problem with a calculation
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
problem with a calculation
Posted: Sun Nov 26, 2017 09:21 PM
on my application the total is 58.29
but if I make the calc the total is 58.28
why it los a 0,01 ?
nTotDoc:= 63.65
nTotRitenute:= 5.37
nTotDovuto := nTotDoc-nTotRitenute

how I can make to have the same result ?

my app



another app ( not mine)

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: problem with a calculation
Posted: Mon Nov 27, 2017 05:29 AM

When you calculate Rit. d'acconto, round of the result to 2 decimal places.
Eg Rit... := Round( <calculation>, 2 )

Regards



G. N. Rao.

Hyderabad, India
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: problem with a calculation
Posted: Mon Nov 27, 2017 04:53 PM
Code (fw): Select all Collapse
#Include "FiveWin.ch"

#xtranslate round(<nVal>,<nDec>) => val(str(<nVal>,20,<nDec>))

FUNCTION Test_Round()
 
   LOCAL nRound, nTotDoc, nTotDacc, nTotDov
 
   nRound   :=  0.00

   nTotDoc  := 63.65

   nTotDacc :=  5.37

   nTotDov  := ( nTotDoc ) - ( nTotDacc )

   nRound := Round( Val( StrZero( nTotDov, 12, 2 ) ), 4 )
 
   ? ROUND( nRound, 2 )  // 58.28
 
RETURN NIL
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: problem with a calculation
Posted: Wed Nov 29, 2017 10:08 AM
karinha wrote:
Code (fw): Select all Collapse
#Include "FiveWin.ch"

#xtranslate round(<nVal>,<nDec>) => val(str(<nVal>,20,<nDec>))

FUNCTION Test_Round()
 
   LOCAL nRound, nTotDoc, nTotDacc, nTotDov
 
   nRound   :=  0.00

   nTotDoc  := 63.65

   nTotDacc :=  5.37

   nTotDov  := ( nTotDoc ) - ( nTotDacc )

   nRound := Round( Val( StrZero( nTotDov, 12, 2 ) ), 4 )
 
   ? ROUND( nRound, 2 )  // 58.28
 
RETURN NIL


thanks but Nages send me a clear message before
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: problem with a calculation
Posted: Wed Nov 29, 2017 01:43 PM

Hello Silvio,
have you seen this line:

xtranslate round(<nVal>,<nDec>) => val(str(<nVal>,20,<nDec>)) ?

Best regards,
Otto

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: problem with a calculation
Posted: Wed Nov 29, 2017 02:14 PM

No need for such translates.

Clipper, xHarbour and Harbour natively provide function ROUND( nvalue, nDecimals )

Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: problem with a calculation
Posted: Tue Jan 16, 2018 11:11 AM

there is a bug on harbour
not run round function
but now I tried with
#xtranslate round(<nVal>,<nDec>) => val(str(<nVal>,20,<nDec>))
and run ok

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: problem with a calculation
Posted: Tue Jan 16, 2018 01:30 PM
there is a bug on harbour
not run round function

Is it?
May I know what is the bug?
Can you give some examples?
Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: problem with a calculation
Posted: Fri Jan 19, 2018 09:05 PM

I wrong topic sorry

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion