简体   繁体   English

简化一个长布尔表达式

[英]Simplify a long boolean expression

Im pretty new to this plattform and well I have a trouble regarding boolean expression in my CS-class.我对这个平台很陌生,而且我在我的 CS 类中遇到了布尔表达式的问题。 I have to simplifly this boolean expression and have no clue how to do this.我必须简化这个布尔表达式,但不知道如何做到这一点。

double x ;双 x ; double y ;双 y ;

boolean b = ( (y < -x) ^ (5 * x >= y) ) && ( (x < -y) != (x >= y * 0.2) )布尔 b = ( (y < -x) ^ (5 * x >= y) ) && ( (x < -y) != (x >= y * 0.2) )

Thanks for the answer谢谢你的回答

Assuming pure math, y < -x is equivalent to x < -y , 5 * x >= y is equivalent to x >= y * 0.2 and whateverBoolean1 ^ whateverBoolean2 is equivalent to whateverBoolean1 != whateverBoolean2 .假设纯数学, y < -x等价于x < -y5 * x >= y等价于x >= y * 0.2并且whateverBoolean1 ^ whateverBoolean2等价于whateverBoolean1 != whateverBoolean2 Hence you can omit any side of && operator.因此,您可以省略&&运算符的任何一侧。

I am neglecting freaks of floating point arithmetics (0.2 is not precise number so some counterexample that original and simplified expression are not equivalent could be perhaps found after some effort.)我忽略了浮点算术的怪胎(0.2 不是精确的数字,所以经过一些努力,也许可以找到一些原始和简化表达式不等价的反例。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM