Skip to content

Instantly share code, notes, and snippets.

@drboyer
Created August 27, 2014 03:50
Show Gist options
  • Save drboyer/6a7f21c16873506769d5 to your computer and use it in GitHub Desktop.
Save drboyer/6a7f21c16873506769d5 to your computer and use it in GitHub Desktop.
Truncates a floating point number to an integer in GrADS scripting language.
* Take a floating-point (decimal) number as a parameter and returns a truncated integer (with no decimal point)
function int(num)
outnum = ''
i = 1
while(i < strlen(num))
char = subwrd(num,i)
if(char = '.')
break
else
outnum = outnum%subwrd(num,i)
i = i+1
endif
endwhile
return outnum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment