problem with a calculation

problem with a calculation

Postby Silvio.Falconi » Sun Nov 26, 2017 9: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

Image

another app ( not mine)

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: problem with a calculation

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

Re: problem with a calculation

Postby karinha » Mon Nov 27, 2017 4:53 pm

Code: Select all  Expand view

#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
User avatar
karinha
 
Posts: 7805
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: problem with a calculation

Postby Silvio.Falconi » Wed Nov 29, 2017 10:08 am

karinha wrote:
Code: Select all  Expand view

#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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: problem with a calculation

Postby Otto » Wed Nov 29, 2017 1:43 pm

Hello Silvio,
have you seen this line:
#xtranslate round(<nVal>,<nDec>) => val(str(<nVal>,20,<nDec>)) ?

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: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: problem with a calculation

Postby nageswaragunupudi » Wed Nov 29, 2017 2:14 pm

No need for such translates.

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: problem with a calculation

Postby Silvio.Falconi » 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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: problem with a calculation

Postby nageswaragunupudi » Tue Jan 16, 2018 1: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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: problem with a calculation

Postby Silvio.Falconi » Fri Jan 19, 2018 9:05 pm

I wrong topic sorry
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 45 guests