Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Here is an example of how to truncate a variable to a whole number:

var1=31.75 ;start with real number
varb1=vcvt(var1) ;convert to binary variable
var2=vcvt(varb1) ;convert back to decimal variable
var2=31.0 ;var2 is now 31.0

If you want to round this number instead of truncate,
add the following to the previous code

var3=var1-var2 ;subtract the truncated number
;from the original real number
;(to get just the decimal places)
if(var3>=0.5)
var1=var2+1 ;use an if statement to round
else ;up or round down
var1=var2
nif

  • No labels