1. Tracy Lamb
  2. PowerBuilder
  3. Wednesday, 19 June 2024 20:38 PM UTC

Hi all,

I'm using the Round() function to round numbers.  It seems to be inconsistent, but I may be misunderstanding what's going on.  

I am rounding 20 +/- 0.85.  When I round to 2 digits I get:

19.15 and 20.85

When I round to 1 digit I get:

19.1 and 20.9

Why is it rounding the 2nd decimal place down on the first value, and up on the second value?

~~~Tracy

Accepted Answer
Tracy Lamb Accepted Answer Pending Moderation
  1. Thursday, 20 June 2024 20:44 PM UTC
  2. PowerBuilder
  3. # Permalink

Figured it out... another rookie move... wasn't rounding in all the right places.  I was putting together a small test case when I discovered the issue.

~~~Tracy

Comment
  1. John Fauss
  2. Thursday, 20 June 2024 21:37 PM UTC
Glad you found the cause of the issue. Thanks for letting us know!
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 19 June 2024 20:59 PM UTC
  2. PowerBuilder
  3. # 1

Hi, Tracy - 

The example numeric values you gave don't make sense. Did you mean 20 +/- 0.85?

What data type are you using? If you are using floating-point (real or double PB data types), their decimal representations are nearly always inexact.

Best regards, John

Comment
  1. Tracy Lamb
  2. Wednesday, 19 June 2024 22:31 PM UTC
PB2022 R3 Build 3356.

  1. Helpful
  1. John Fauss
  2. Thursday, 20 June 2024 00:09 AM UTC
I ran a test using PB 2019 R3, Build 2703 - and it produced correct/expected results. I suggest you put together a small test case using PB 2022 R3 Build 3356 to verify that it produces the incorrect results you've observed. Then try switching the runtime for the test app to earlier builds/releases and see if you can observed a build that produces correct results. At that point, you'll have great information on which you can open a bug ticket - and I encourage you to do so.
  1. Helpful 1
  1. Chris Pollach @Appeon
  2. Thursday, 20 June 2024 00:28 AM UTC
Hi Tracy;

Do you have a small test case using the Round ( ) method in PB2022 R3 Build 3356?

Regards .. Chris
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.