nfloat offsetWithPercentage(nfloat percentage, nfloat totalWidth) { var offset = percentage * totalWidth; if (offset < totalWidth.Neg()) { offset = totalWidth.Neg(); } else if (offset > totalWidth) { offset = totalWidth; } return(offset); }