취소
다음에 대한 결과 표시 
다음에 대한 검색 
다음을 의미합니까? 

conversion to integer

The code *almost* works. In the algorithm, after adding 0.5, you need to round down, not up. This is also demonstrated in the link I posted earlier, where it's encapsulated into a subVI.

___________________
Try to take over the world!
0 포인트
11/18 메시지
2,238 조회수

Picky, Picky......기쁨 이모티콘  You are of course correct..........

 

Add 0.5, round toward -Infinity.....

 

Message Edited by tartan5 on 10-08-2008 09:38 AM
0 포인트
12/18 메시지
2,231 조회수

Just out of curiosity, I wonder why there is no "Round toward zero"  (Truncate) function......

 

To be honest, I was a little startled that the "to unsigned word" conversion function actually does implicit rounding.  I understand why it does, it just took me by surprise that it is inherent to the function.

0 포인트
13/18 메시지
2,222 조회수

tartan5 wrote:

Just out of curiosity, I wonder why there is no "Round toward zero"  (Truncate) function......


Well, checking if a number is smaller or larger than 0 and doing the appropriate action is pretty simple. It would probably take longer to do the icon than to write the VI itself. Incidentally, you can also try using the Q&R primitive and divide by 1, but I'm not sure what you'll get with a negative input.


___________________
Try to take over the world!
0 포인트
14/18 메시지
2,196 조회수

tartan5 wrote:

Just out of curiosity, I wonder why there is no "Round toward zero"  (Truncate) function......

 

 


There isn't a "round toward zero" but there is 'round to negative infinity'.  

 

Cory K
0 포인트
15/18 메시지
2,186 조회수
.... and a 'round to nearest'
Cory K
0 포인트
16/18 메시지
2,185 조회수

http://www.pldesignline.com/howto/175801189

 

Good article on different rounding algorithms.........

 

The "round to nearest" should really be called "Round to nearest even", since that is what it does.....

0 포인트
17/18 메시지
2,181 조회수

tartan5 wrote:

 

The "round to nearest" should really be called "Round to nearest even", since that is what it does.....


No, it isn't. It only rounds to the nearest even under these circumstances:

  1. The even number really is the nearest integer.
  2. It's halfway between two integers. This is sometimes refered to as "ties to even", so you could call it "Round to nearest, ties to even".

___________________
Try to take over the world!
0 포인트
18/18 메시지
2,161 조회수