boolean - 简化 boolean 方程

标签 boolean

我有一个 boolean 方程,想简化它。帮忙解决一下。

bool needLoad = isA || (!isA && !isB);

之后我使用

if (needLoad){
       if (isA)
           rawData = Configuration.GetData();
       if (!isA && !isB)
           rawData = Configuration.GetOtherData();
}

最佳答案

您可以使用德摩根恒等式简化方程:

  isA || (!isA && !isB)
= isA || !(isA || isB)
= isA || !isB

关于boolean - 简化 boolean 方程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17061733/

相关文章:

arrays - Delphi XE6,带有 boolean 成员字段的记录的3D数组,不会建立

vector - Armadillo C++ 线性代数库 : How to create vector of boolean

Java如何使用用户的 boolean 输入结束do-while循环?

ruby-on-rails - rails : update_attributes not updating all attributes

Java boolean[] 到 byte[] 并返回

bash - grep stderr 和上一个命令的 stdout

c++ - 在多线程 C++ 应用程序中,我是否需要互斥锁来保护简单的 boolean 值?

c++ - if 的感觉——这怎么可能起作用

Java类和返回值

java - 替换不能使用枚举的 boolean 参数?