Currently using Math.round(number / 256) * 256
, but 320
is rounded to 256
.
Asked
Active
Viewed 56 times
1

sunknudsen
- 6,356
- 3
- 39
- 76
-
1`ceil` instead of `round`? – luk2302 Sep 12 '22 at 11:23
-
1Really no reason to have this as yet another question on SO. Googling the question title reveals exactly the linked duplicate as the very first hit. (And even less of a reason to have 2 upvotes) – luk2302 Sep 12 '22 at 11:25
-
If you want to *increment*, does that mean you want 256 to result in 512, and 512 to result in 768, ...etc? – trincot Sep 12 '22 at 11:28
1 Answers
4
Math.ceil(number / 256) * 256

Vojin Purić
- 2,140
- 7
- 9
- 22
-
I should really post a question titled "how do I round a number upwards to multiples of 123" and earn me some points... what is this rep farming... – luk2302 Sep 12 '22 at 14:23