取消
显示结果 
搜索替代 
您的意思是: 

How to implement this logic

Hi,

 

Could you please let me know how can I implemet this logic

 

 

if  2.39<x<2.4  then y=4.8

if  2.42<x<2.45  then y=5.0

if  2.47<x<2.50  then y=5.2

.

.

.

 

All the values are hard coded

 

Thanks

 

0 项奖励
1 条消息(共 12 条)
4,788 次查看

As usual, show us what you got.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 项奖励
2 条消息(共 12 条)
4,784 次查看

And what if x <= 2.39?

2.4 <= x <=2 .42?

2.45 <= x <=2 .47?

Or x >= 2.50?

 

There are holes in your ranges.

0 项奖励
3 条消息(共 12 条)
4,775 次查看

Then the value is invalid,

 

it should be actually like this

 

2.39<=x<=2.4 then y=4.8

2.42<=x<=2.45 then y=5

.

.

 

0 项奖励
4 条消息(共 12 条)
4,771 次查看

I would multiply the value by 100 then wire that into a case structure selector terminal.

 

The case structure would have 4 cases defined.

 

239 .. 240    it outputs a 4.8 to the tunnel

242 .. 245    it outputs a 5.0 to the tunnel

247 .. 250    it outputs a 5.2 to the tunnel

Default        it outputs a 0 or some other value that you define that you want to represent as an invalid value.

 

 

0 项奖励
5 条消息(共 12 条)
4,768 次查看

You could use a formula node from the Structures menu.  It uses expressions similar to C.

Capture.PNG

aputman
0 项奖励
6 条消息(共 12 条)
4,737 次查看

Multiplying by 100 and then comparing integer is always better then comparing floating value. Opt for 'X100'

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 项奖励
7 条消息(共 12 条)
4,706 次查看

@Ranjeet_Singh wrote:

Multiplying by 100 and then comparing integer is always better then comparing floating value. Opt for 'X100'


 

So... what happens if the number has three decimal places?  😉

 

More correctly stated, I guess you could say "multiply the numbers to be compared by 10^x, where x equals the precision of your most precise number.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 项奖励
8 条消息(共 12 条)
4,665 次查看

@billko wrote:

@Ranjeet_Singh wrote:

Multiplying by 100 and then comparing integer is always better then comparing floating value. Opt for 'X100'


 

So... what happens if the number has three decimal places?  😉

 

More correctly stated, I guess you could say "multiply the numbers to be compared by 10^x, where x equals the precision of your most precise number.


This is an excellent point.  Given the example, multiply by 100 would work fine.  But you also need to be aware of rounding, which is a whole other issue you probably don't want to think about.  When converting to an integer, the number will round toward 0.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 项奖励
9 条消息(共 12 条)
4,648 次查看

@crossrulz wrote:

@billko wrote:

@Ranjeet_Singh wrote:

Multiplying by 100 and then comparing integer is always better then comparing floating value. Opt for 'X100'


 

So... what happens if the number has three decimal places?  😉

 

More correctly stated, I guess you could say "multiply the numbers to be compared by 10^x, where x equals the precision of your most precise number.


This is an excellent point.  Given the example, multiply by 100 would work fine.  But you also need to be aware of rounding, which is a whole other issue you probably don't want to think about.  When converting to an integer, the number will round toward 0.


But by multiplying as I have shown, that should result in all numbers being integers... or are you saying that if you specified 0.5 was internally represented as 0.499 you are in danger of coming up with 4 as your integer, not 5?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 项奖励
10 条消息(共 12 条)
4,644 次查看