08-13-2009 10:07 AM
Hi, I'm trying to translate some equations done in Excel into LabVIEW.
Does anyone know what the LabVIEW equivilant is for the Excel command:
ROUND(x,0)
Also, what is the equivilant for
INT(x)
Many thanks, Alec
Solved! Go to Solution.
08-13-2009 10:12 AM - edited 08-13-2009 10:13 AM
Here you go:
The top 3 functions, from left to right:
1) Round to nearest
2) Round down
3) Round up
The palette below shows all types of numeric type conversions.
To convert to int, you can do I64, I32, I16, or I8
08-13-2009 10:17 AM
08-13-2009 10:18 AM
To be honest, I'm not sure because I dont use excel much.
What exactly does ROUND(x,0) do in excel?
Once I know the functionality, I can point you to a better function.
08-13-2009 10:22 AM
Round Numbers
The ROUND Function will round numbers to a specified number of digits. If the number of digits is negative, it will round to the left of the decimal point. If zero it will round to the nearest Integer (whole number).
=ROUND(1.5,0) will result in a value of 2
=ROUND(1.4,0) will result in a value of 1
Round Numbers Up
The ROUNDUP function will round numbers up, away from zero.
=ROUNDUP(1.4,0) will result in a value of 2
Round Numbers Down
The ROUNDDOWN function will round numbers down, toward zero.
=ROUNDDOWN(1.6,0) will result in a value of 1
INT (although less flexible) can also be used. =INT(1.6) will also result in 1
08-13-2009 10:26 AM
If you are going to input the second parameter as 0 : ROUND(x,0)
Then you will want to use round to nearest.
The cutoff with be .5
An odd number will round up, and an even number will round down.
Ex:
13.5 --> 14
16.5 --> 16
11.3 --> 11
11.8 --> 12
08-13-2009 10:28 AM
08-13-2009 10:59 AM - edited 08-13-2009 11:01 AM
Matthew Kelton wrote:
The Rounds in LabVIEW do not have decimal place inputs, so are equivalent to the ROUND, ROUNDUP, and ROUNDDOWN with the second parameter set to 0. ROUND is Round to Nearest. IF you want decimal places, you will have to do your own coding to shift the decimal places and do rounding.
So Round(x,d) will impement as I missed the negate of d on the first shot
08-13-2009 11:03 AM
08-13-2009 11:21 AM