Help about function ROUND. 
Author Message
 Help about function ROUND.

My problem is...
      Round(97.45 * 10 / 100, 2) = 9.74
when it should be 9.75.

Someone Can help me ?
Thanks.



Thu, 19 Feb 2004 02:02:51 GMT  
 Help about function ROUND.
hello jose,
you should do some more calculations to get the wished result.
1st get more division by 5 before round()
2nd multiplicate the rounded result with 5
this is to get steps of .05 as you need


Thu, 19 Feb 2004 02:31:33 GMT  
 Help about function ROUND.
Hi Jose

For my needs I've made a function for that.

FUNCTION FcRound(nBetr,fk)
  // usual fk = 5 if rounding to 0.5,   2 if rounding to 0.2 etc.
  LOCAL n

  IF nBetr <> 0
    n    := Int(Abs(nBetr)*100/fk+0.5)/(100/fk)
    IF nBetr < 0 ; nBetr  := -n
    ELSE         ; nBetr  :=  n
    ENDIF
  ENDIF
  RETURN nBetr

Function call:
nAmount    := FcRound(nAmount,5)

HTH

Walt



Quote:
> My problem is...
>       Round(97.45 * 10 / 100, 2) = 9.74
> when it should be 9.75.

> Someone Can help me ?
> Thanks.



Thu, 19 Feb 2004 11:43:14 GMT  
 Help about function ROUND.
1. In clipper 5.3 there is CORRECT answer

2. In DBase or FOXbase, there is WRONG answer - it seems to be bug! Use
cliper 5.3!



Thu, 19 Feb 2004 17:18:09 GMT  
 Help about function ROUND.
Hello Jose,

Quote:
> My problem is...
>       Round(97.45 * 10 / 100, 2) = 9.74
> when it should be 9.75.

Try this:
Int(97.45 * 20 + 0.5) / 20

Best regards

Otto
Bern, Switzerland

Using Clipper 5.2e, Blinker 5.10, Clip-4-Win 3.0,
      PageScript 2.0, TextPad 4.3



Fri, 20 Feb 2004 02:43:12 GMT  
 Help about function ROUND.
ROUND( (97.45 * 10 / 100)+0,00001,2)

or Replace ROUND with ROUNDOK

FUNCTION ROUNDOK( nNumberm, nDigm)
    if pcount()=1
      nDigm=2
   endif
RETURN (ROUND(nNumberm+iif(Nnumberm<0,-0.00001,0.00001),nDigm)



Quote:
> My problem is...
>       Round(97.45 * 10 / 100, 2) = 9.74
> when it should be 9.75.

> Someone Can help me ?
> Thanks.



Fri, 20 Feb 2004 03:55:11 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. HELP HELP HELP - round function error

2. Round Function

3. Bug in C5 Round function?

4. problem for function round

5. LOGO-L> Re: function ROUND

6. function ROUND

7. Need Rexx function to get numbers rounded

8. round rounds right?

9. A simple? rounding function

10. round() function strange behaviour

11. Round and Round we go

12. Ord Function HELP Please HELP HELP HELP

 

 
Powered by phpBB® Forum Software