Active IQ Unified Manager Discussions

WFA Function to roundup

rogerhinson
3,100 Views

Hey all,

 

Hopefully this is quick for someone..  I'm just trying to create a function to roundup a value to the nearest integer.  I'm using WFA v2.2.  I've created this:

 

def roundup (num)
{
Math.ceil(num);
}

 

My problem is that it returns a decimal value and OnTap needs an integer value to increase the size of a volume.  Example, if I enter 12, I get 12.0.  If I enter 12.5, I get 13.0

 

I've tried using ((int) Math.ceil(num)); to return an integer, but I get an error that it's an Illegal expression.

 

Thanks,

Roger

 

 

 

1 ACCEPTED SOLUTION

geringer
3,092 Views

Roger,

     Instead of Math.Ciel(num)    try Integer.ValueOf(num).  If you look at the "actualVolumeSize" function, it appears that "return (int)(Math.Ciel(num))" may also work, or just "(int)(num)" if you really just need the integer component and are not that concerned about rounding up.

 

 

Mike

View solution in original post

2 REPLIES 2

geringer
3,093 Views

Roger,

     Instead of Math.Ciel(num)    try Integer.ValueOf(num).  If you look at the "actualVolumeSize" function, it appears that "return (int)(Math.Ciel(num))" may also work, or just "(int)(num)" if you really just need the integer component and are not that concerned about rounding up.

 

 

Mike

rogerhinson
3,088 Views

Thanks Mike,

 

Just putting the int on the return worked.  I ended up with this.

 

def roundup (num)
{
answer= Math.ceil(num);
return (int)(answer)
}

 

 

Public