Preview:
float rstoc(x) {
  float decimal = abs(x - trunc(x));

  float random_selector = (float)rand() / RAND_MAX;

  float adjustor;
  if (random_selector < decimal) adjustor = 1;
  else adjustor = 0;

  // consider sign
  if(x < 0) adjustor = -1 * adjustor;

  return trunc(x) + adjustor;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter