05-08-2015 01:16 AM
Hello
Is there any block which can perform the operation given below ,
Input: 0.265 Output : 0.2
Input: 0.376 Output : 0.3
Basically the input has to be rounded off to just one decimal place.
Thanks
05-08-2015 02:50 AM
You can create your own subVI.
multiply by 10, round to -infinity, divide by 10.
(Be aware that some of those fractional numbers (e.g. 0.1) don't have an exact representation in binary.)
05-08-2015 08:08 AM
Are you wanting to round, or are you wanting to truncate?
Rounding of 0.265 to one decimal place would give you 0.3. Likewise, rounding 0.376 would give you 0.4.
To truncate, I'd recommend converting your number to a string, searching the string for the decimal, taking the string subset to one character past the decimal, and converting back to a number.
Hope this helps.
05-08-2015 08:32 AM
DanRen_IQA wrote:
To truncate, I'd recommend converting your number to a string, searching the string for the decimal, taking the string subset to one character past the decimal, and converting back to a number.
The Multiply, Round to -INF, Divide is a lot more efficient than converting data types. I would not recommend the method of converting to strings and back.