Since the multiplication to get from [0.0f .. 1.0f] to [0 .. UInt32.MaxValue] itself can be approximative, the order of operations, which obviously has obviously the property that you want, is multiplied, then clamped, then round.
The maximum value for commit is a float immediately below 2 32 that is 4294967040.0f. Although this number is several units lower than UInt32.MaxValue, which allows any larger value to mean conversion overflow by UInt32.
Any of the lines below should work:
y = (uint)round(min(max(x * 4294967040.0F, 0.0F), 4294967040.0F))
UInt32.MaxValue. , (, , 4294967040 , 1.0f, ) 4294967040 1.0f .
[0.0f.. 1.0f] , , , :
y = (uint)round(min(max(x, 0.0F), 1.0F) * 4294967040.0F)
, , UInt32.MaxValue:
if (x <= 0.0f) y = 0
else if (x < 0.5f) y = (uint) round (x * 4294967296.0F)
else if (x >= 1.0f) y = UInt32.MaxValue
else y = UInt32.MaxValue - (uint) round ((1.0f - x) * 4294967296.0F)
, x y, ( 0,5f) UInt32.MaxValue. , , , . , , 0.0f 1.0f, 0.5f, :
if (x < 0.5f)
{
if (x <= 0.0f) y = ...
else y = ...
}
else
{
if (x >= 1.0f) y = ...
else y = ...
}