diff options
author | Dietrich <dgeisler50@gmail.com> | 2015-04-20 14:56:59 -0600 |
---|---|---|
committer | Dietrich <dgeisler50@gmail.com> | 2015-04-20 14:56:59 -0600 |
commit | 1621e22e7758046e1262b22410a48250388abf29 (patch) | |
tree | f2a7e4b07389e4748200bfc47a33db60ba5aeb23 /Source/Basetypes | |
parent | ac54b6451035fd3c0fab62ce1044d48114053c15 (diff) |
renamed fp32 to BigFloat
Diffstat (limited to 'Source/Basetypes')
-rw-r--r-- | Source/Basetypes/Basetypes.csproj | 2 | ||||
-rw-r--r-- | Source/Basetypes/BigFloat.cs (renamed from Source/Basetypes/fp32.cs) | 60 |
2 files changed, 31 insertions, 31 deletions
diff --git a/Source/Basetypes/Basetypes.csproj b/Source/Basetypes/Basetypes.csproj index 84a6ffd1..4ecdee8d 100644 --- a/Source/Basetypes/Basetypes.csproj +++ b/Source/Basetypes/Basetypes.csproj @@ -163,7 +163,7 @@ </Compile>
<Compile Include="BigDec.cs" />
<Compile Include="BigNum.cs" />
- <Compile Include="FP32.cs" />
+ <Compile Include="BigFloat.cs" />
<Compile Include="Rational.cs" />
<Compile Include="Set.cs" />
</ItemGroup>
diff --git a/Source/Basetypes/fp32.cs b/Source/Basetypes/BigFloat.cs index 5d76737b..d1ee73a4 100644 --- a/Source/Basetypes/fp32.cs +++ b/Source/Basetypes/BigFloat.cs @@ -19,7 +19,7 @@ namespace Microsoft.Basetypes /// A representation of a 32-bit floating point value /// Note that this value has a 1-bit sign, 8-bit exponent, and 23-bit mantissa /// </summary> - public struct FP32 + public struct BigFloat { //Please note that this code outline is copy-pasted from BigDec.cs @@ -43,7 +43,7 @@ namespace Microsoft.Basetypes } } - public static readonly FP32 ZERO = FromInt(0); + public static readonly BigFloat ZERO = FromInt(0); private static readonly BIM two = new BIM(2); private static readonly BIM ten = new BIM(10); @@ -55,17 +55,17 @@ namespace Microsoft.Basetypes //For a complete summary of where this class has been added, simply view constructor references [Pure] - public static FP32 FromInt(int v) { - return new FP32(v, 0, v < 0); //TODO: modify for correct fp representation + public static BigFloat FromInt(int v) { + return new BigFloat(v, 0, v < 0); //TODO: modify for correct fp representation } [Pure] - public static FP32 FromBigInt(BIM v) { - return new FP32(v, 0, v < 0); //TODO: modify for correct fp representation + public static BigFloat FromBigInt(BIM v) { + return new BigFloat(v, 0, v < 0); //TODO: modify for correct fp representation } [Pure] - public static FP32 FromString(string v) { + public static BigFloat FromString(string v) { //TODO: completely copied from BigDec.cs at the moment if (v == null) throw new FormatException(); @@ -100,10 +100,10 @@ namespace Microsoft.Basetypes fractionLen = fractionLen - 1; } } - return new FP32(integral - fraction, exponent, integral.Sign == -1); + return new BigFloat(integral - fraction, exponent, integral.Sign == -1); } - internal FP32(BIM mantissa, int exponent, bool isNegative) { + internal BigFloat(BIM mantissa, int exponent, bool isNegative) { this.isNegative = isNegative; if (mantissa.IsZero) { this.mantissa = mantissa; @@ -128,10 +128,10 @@ namespace Microsoft.Basetypes public override bool Equals(object obj) { if (obj == null) return false; - if (!(obj is FP32)) + if (!(obj is BigFloat)) return false; - return (this == (FP32)obj); + return (this == (BigFloat)obj); } [Pure] @@ -152,7 +152,7 @@ namespace Microsoft.Basetypes // ``floor`` rounds towards negative infinity (like SMT-LIBv2's to_int). /// <summary> - /// Computes the floor and ceiling of this FP32. Note the choice of rounding towards negative + /// Computes the floor and ceiling of this BigFloat. Note the choice of rounding towards negative /// infinity rather than zero for floor is because SMT-LIBv2's to_int function floors this way. /// </summary> /// <param name="floor">The Floor (rounded towards negative infinity)</param> @@ -277,28 +277,28 @@ namespace Microsoft.Basetypes // Basic arithmetic operations [Pure] - public FP32 Abs { + public BigFloat Abs { //TODO: fix for fp functionality get { - return new FP32(BIM.Abs(this.mantissa), this.exponent, false); + return new BigFloat(BIM.Abs(this.mantissa), this.exponent, false); } } [Pure] - public FP32 Negate { + public BigFloat Negate { //TODO: Modify for correct fp functionality get { - return new FP32(BIM.Negate(this.mantissa), this.exponent, this.Mantissa >= 0); + return new BigFloat(BIM.Negate(this.mantissa), this.exponent, this.Mantissa >= 0); } } [Pure] - public static FP32 operator -(FP32 x) { + public static BigFloat operator -(BigFloat x) { return x.Negate; } [Pure] - public static FP32 operator +(FP32 x, FP32 y) { + public static BigFloat operator +(BigFloat x, BigFloat y) { //TODO: Modify for correct fp functionality BIM m1 = x.mantissa; int e1 = x.exponent; @@ -316,18 +316,18 @@ namespace Microsoft.Basetypes e2 = e2 - 1; } - return new FP32(m1 + m2, e1, true); + return new BigFloat(m1 + m2, e1, true); } [Pure] - public static FP32 operator -(FP32 x, FP32 y) { + public static BigFloat operator -(BigFloat x, BigFloat y) { return x + y.Negate; } [Pure] - public static FP32 operator *(FP32 x, FP32 y) { + public static BigFloat operator *(BigFloat x, BigFloat y) { //TODO: modify for correct fp functionality - return new FP32(x.mantissa * y.mantissa, x.exponent + y.exponent, false); + return new BigFloat(x.mantissa * y.mantissa, x.exponent + y.exponent, false); } @@ -353,44 +353,44 @@ namespace Microsoft.Basetypes } [Pure] - public int CompareTo(FP32 that) { + public int CompareTo(BigFloat that) { //TODO: Modify for correct fp functionality if (this.mantissa == that.mantissa && this.exponent == that.exponent) { return 0; } else { - FP32 d = this - that; + BigFloat d = this - that; return d.IsNegative ? -1 : 1; } } [Pure] - public static bool operator ==(FP32 x, FP32 y) { + public static bool operator ==(BigFloat x, BigFloat y) { return x.CompareTo(y) == 0; } [Pure] - public static bool operator !=(FP32 x, FP32 y) { + public static bool operator !=(BigFloat x, BigFloat y) { return x.CompareTo(y) != 0; } [Pure] - public static bool operator <(FP32 x, FP32 y) { + public static bool operator <(BigFloat x, BigFloat y) { return x.CompareTo(y) < 0; } [Pure] - public static bool operator >(FP32 x, FP32 y) { + public static bool operator >(BigFloat x, BigFloat y) { return x.CompareTo(y) > 0; } [Pure] - public static bool operator <=(FP32 x, FP32 y) { + public static bool operator <=(BigFloat x, BigFloat y) { return x.CompareTo(y) <= 0; } [Pure] - public static bool operator >=(FP32 x, FP32 y) { + public static bool operator >=(BigFloat x, BigFloat y) { return x.CompareTo(y) >= 0; } } |