I can tell you the “what”
For RAM sizes of less than 128 MB, don’t do rounding.
For RAM sizes of greater than 128 MB, round to the nearest multiple of 32 based on a rounding midpoint of 16.
example:
For RAM that rounds to 511 MB or 513 MB, it would round to 512 MB.
As to the “why”, I speculate that it is based on the idea that RAM is binary and 2^5 (32) is a typical rounding breakpoint in binary vs integer base 10 rounding.