using Microsoft.VisualStudio.TestTools.UnitTesting;
Zustand zustand = Zustand.Normal;
public Zahl(Zustand zustand = Zustand.Normal, double wert = 0)
public bool istDefiniert() => (zustand == Zustand.Normal);
public bool istUndefiniert() => !istDefiniert();
override public string ToString()
if (zustand == Zustand.Undefiniert) return "Undefiniert";
public static Zahl addition(Zahl a, Zahl b)
if (a.istUndefiniert() || b.istUndefiniert())
return new Zahl(Zustand.Undefiniert);
return new Zahl(Zustand.Normal, a.wert + b.wert);
public static Zahl subtraktion(Zahl a, Zahl b)
if (a.istUndefiniert() || b.istUndefiniert())
return new Zahl(Zustand.Undefiniert);
return new Zahl(Zustand.Normal, a.wert - b.wert);
public static Zahl multiplikation(Zahl a, Zahl b)
if (a.istUndefiniert() || b.istUndefiniert()) {
return new Zahl(Zustand.Undefiniert);
return new Zahl(Zustand.Normal, a.wert * b.wert);
public static Zahl division(Zahl a, Zahl b)
if (a.istUndefiniert() && b.istUndefiniert())
return new Zahl(Zustand.Undefiniert);
if (a.wert == 0 && b.wert == 0)
return new Zahl(Zustand.Normal, 0);
return new Zahl(Zustand.Undefiniert);
return new Zahl(Zustand.Normal, a.wert / b.wert);
public void testDivisionDurchNull()
Zahl a = new Zahl(Zustand.Normal, 123);
Zahl b = new Zahl(Zustand.Normal, );
Zahl c = Zahl.division(a, b);
public void testNullDividiertDurchNull()
Zahl a = new Zahl(Zustand.Normal, 0);
Zahl b = new Zahl(Zustand.Normal, 0);
Zahl c = Zahl.division(a, b);
public void testNormaleDivision()
Zahl a = new Zahl(Zustand.Normal, 123);
Zahl b = new Zahl(Zustand.Normal, 0);
Zahl c = Zahl.division(a, b);
public void testDoubleDivision()
Zahl a = new Zahl(Zustand.Normal, 12);
Zahl b = new Zahl(Zustand.Normal, 6);
Zahl c = Zahl.division(a, b);
Assert.IsTrue((a.wert / b.wert) == c.wert);
public void sinnloserTest()
double largestDouble = System.Math.Pow(2, 53);
Zahl a = new Zahl(Zustand.Normal, largestDouble);
Zahl b = new Zahl(Zustand.Normal, 1);
Zahl c = Zahl.division(a, b);
Assert.IsTrue((a.wert / b.wert) == c.wert);