Kleber Gracia

Greenhorn

Posts: 2

posted 2 years ago

Personally, I found the solution to a post that opened there a week ago, is working for all numbers below 9.00, typing eg 8.99 it calculates 9:00, another value it calculates 5.10 to 9.00, is a standard for stores, but the type 9.00 and 12, nine, nine should be the same, since the 12, would have to be 19.00, and there on. The following algorithm, if someone can help me thank you.

a

Kleber Gracia

Greenhorn

Posts: 2

posted 2 years ago

Good personal afternoon okay, I could decipher in parts, the rule for 9.00 and 19.00, but we lack the rest follows suit.

1.45 -> 9.00

5.90 -> 9.00

4.90 -> 9.00

9.00 -> 9.00

---------------

9.10 -> 19.00

18.47 -> 19.00

----------------

for it already calculates, now I need:

19.10 -> 29.00

25.47 -> 29.00

29.10 -> 39.00

and there forward.

The following code done to 9:19 missing a generic that does everything.

Tks

1.45 -> 9.00

5.90 -> 9.00

4.90 -> 9.00

9.00 -> 9.00

---------------

9.10 -> 19.00

18.47 -> 19.00

----------------

for it already calculates, now I need:

19.10 -> 29.00

25.47 -> 29.00

29.10 -> 39.00

and there forward.

The following code done to 9:19 missing a generic that does everything.

Tks

a

posted 2 years ago

Wow. That is a lot of code for a straightforward mathematical operation. I was able to get it down to four big decimal method calls chained together. The four operations were...

1. Add one to get it to the nearest whole tens digit (so that it can be rounded as a tens digit, instead of rounded as "around the nine").

2. Divide by ten, zero scale, round up, in order to get rid of the unwanted digits.

3. Multiply by ten, to get it back into the tens digit.

4. Subtract one to undo step one.

And this will work for every case that you listed.

Henry

1. Add one to get it to the nearest whole tens digit (so that it can be rounded as a tens digit, instead of rounded as "around the nine").

2. Divide by ten, zero scale, round up, in order to get rid of the unwanted digits.

3. Multiply by ten, to get it back into the tens digit.

4. Subtract one to undo step one.

And this will work for every case that you listed.

Henry