32 lines
462 B
C#
32 lines
462 B
C#
using System;
|
|
using hwo.bitworks.identity;
|
|
|
|
namespace hwo.bitworks
|
|
{
|
|
public class XOR : LogicBase
|
|
{
|
|
public XOR(params LogicBase[] sources)
|
|
:base(sources)
|
|
{
|
|
}
|
|
|
|
public override bool value()
|
|
{
|
|
bool r = false;
|
|
|
|
foreach (LogicBase source in sources){
|
|
if (source.value()){
|
|
r = !r;
|
|
}
|
|
}
|
|
|
|
return r;
|
|
}
|
|
|
|
public override BitIdentity identity()
|
|
{
|
|
return new BitIdentity(BitOperation.XOR,identities(this.sources));
|
|
}
|
|
}
|
|
}
|