Rounding up a variable

Anything that doesn't fit elsewhere.
Post Reply
Posts: 29
Joined: Mon Sep 14, 2009 6:33 am

Rounding up a variable

Post by auatai »

Is there any function to round up a floating point variable within the hoc code?

thanks and regards
Site Admin
Posts: 5784
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: Rounding up a variable

Post by ted »

int truncates toward 0, returning the integer portion of its argument. So roll your own:

Code: Select all

func round() {
  if ($1>0) {
    return int($1+0.5)
  } else {
    return int($1-0.5)
Post Reply