Returned to my own naming convention - at the latest, the 'SingleInt32Union' would raise the question about where there is only a single int32 in that union
git-svn-id: file:///srv/devel/repo-conversion/nusu@295 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
5fb5b1f568
commit
2210973528
|
@ -36,8 +36,8 @@ namespace Nuclex.Support.Collections {
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// In principle, it works like a multimap, associating keys with a number of values
|
/// In principle, it works like a multimap, associating keys with a number of values
|
||||||
/// and allowing you to look up a values by their keys. Unlike a multimap, it will
|
/// and allowing you to look up values by their keys. Unlike a multimap, it will try
|
||||||
/// avoid handing out a previously provided value again.
|
/// to avoid handing out a previously provided value again as long as possible.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// A typical usage would be to set up a mapping between situations and dialogue lines.
|
/// A typical usage would be to set up a mapping between situations and dialogue lines.
|
||||||
|
@ -282,6 +282,6 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Nuclex { namespace Support { namespace Collections
|
} // namespace Nuclex.Support.Collections
|
||||||
|
|
||||||
#endif // !(WINDOWS_PHONE || XBOX360)
|
#endif // !(WINDOWS_PHONE || XBOX360)
|
||||||
|
|
|
@ -44,11 +44,11 @@ namespace Nuclex.Support {
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static class FloatHelper {
|
public static class FloatHelper {
|
||||||
|
|
||||||
#region struct FloatInt32Union
|
#region struct FloatIntUnion
|
||||||
|
|
||||||
/// <summary>Union of a floating point variable and an integer</summary>
|
/// <summary>Union of a floating point variable and an integer</summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
private struct FloatInt32Union {
|
private struct FloatIntUnion {
|
||||||
|
|
||||||
/// <summary>The union's value as a floating point variable</summary>
|
/// <summary>The union's value as a floating point variable</summary>
|
||||||
[FieldOffset(0)]
|
[FieldOffset(0)]
|
||||||
|
@ -64,13 +64,13 @@ namespace Nuclex.Support {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion // struct FloatInt32Union
|
#endregion // struct FloatIntUnion
|
||||||
|
|
||||||
#region struct DoubleInt64Union
|
#region struct DoubleLongUnion
|
||||||
|
|
||||||
/// <summary>Union of a double precision floating point variable and a long</summary>
|
/// <summary>Union of a double precision floating point variable and a long</summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
private struct DoubleInt64Union {
|
private struct DoubleLongUnion {
|
||||||
|
|
||||||
/// <summary>The union's value as a double precision floating point variable</summary>
|
/// <summary>The union's value as a double precision floating point variable</summary>
|
||||||
[FieldOffset(0)]
|
[FieldOffset(0)]
|
||||||
|
@ -86,7 +86,7 @@ namespace Nuclex.Support {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion // struct DoubleInt64Union
|
#endregion // struct DoubleLongUnion
|
||||||
|
|
||||||
/// <summary>A floating point value that holds a positive zero</summary>
|
/// <summary>A floating point value that holds a positive zero</summary>
|
||||||
public const float PositiveZeroFloat = +0.0f;
|
public const float PositiveZeroFloat = +0.0f;
|
||||||
|
@ -150,8 +150,8 @@ namespace Nuclex.Support {
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static bool AreAlmostEqual(float left, float right, int maxUlps) {
|
public static bool AreAlmostEqual(float left, float right, int maxUlps) {
|
||||||
var leftUnion = new FloatInt32Union();
|
var leftUnion = new FloatIntUnion();
|
||||||
var rightUnion = new FloatInt32Union();
|
var rightUnion = new FloatIntUnion();
|
||||||
|
|
||||||
leftUnion.Float = left;
|
leftUnion.Float = left;
|
||||||
rightUnion.Float = right;
|
rightUnion.Float = right;
|
||||||
|
@ -214,8 +214,8 @@ namespace Nuclex.Support {
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static bool AreAlmostEqual(double left, double right, long maxUlps) {
|
public static bool AreAlmostEqual(double left, double right, long maxUlps) {
|
||||||
var leftUnion = new DoubleInt64Union();
|
var leftUnion = new DoubleLongUnion();
|
||||||
var rightUnion = new DoubleInt64Union();
|
var rightUnion = new DoubleLongUnion();
|
||||||
|
|
||||||
leftUnion.Double = left;
|
leftUnion.Double = left;
|
||||||
rightUnion.Double = right;
|
rightUnion.Double = right;
|
||||||
|
@ -260,7 +260,7 @@ namespace Nuclex.Support {
|
||||||
/// The memory contents of the floating point value interpreted as an integer
|
/// The memory contents of the floating point value interpreted as an integer
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static int ReinterpretAsInt(this float value) {
|
public static int ReinterpretAsInt(this float value) {
|
||||||
FloatInt32Union union = new FloatInt32Union();
|
FloatIntUnion union = new FloatIntUnion();
|
||||||
union.Float = value;
|
union.Float = value;
|
||||||
return union.Int;
|
return union.Int;
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ namespace Nuclex.Support {
|
||||||
/// interpreted as an integer
|
/// interpreted as an integer
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static long ReinterpretAsLong(this double value) {
|
public static long ReinterpretAsLong(this double value) {
|
||||||
DoubleInt64Union union = new DoubleInt64Union();
|
DoubleLongUnion union = new DoubleLongUnion();
|
||||||
union.Double = value;
|
union.Double = value;
|
||||||
return union.Long;
|
return union.Long;
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ namespace Nuclex.Support {
|
||||||
/// The memory contents of the integer value interpreted as a floating point value
|
/// The memory contents of the integer value interpreted as a floating point value
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static float ReinterpretAsFloat(this int value) {
|
public static float ReinterpretAsFloat(this int value) {
|
||||||
FloatInt32Union union = new FloatInt32Union();
|
FloatIntUnion union = new FloatIntUnion();
|
||||||
union.Int = value;
|
union.Int = value;
|
||||||
return union.Float;
|
return union.Float;
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ namespace Nuclex.Support {
|
||||||
/// floating point value
|
/// floating point value
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static double ReinterpretAsDouble(this long value) {
|
public static double ReinterpretAsDouble(this long value) {
|
||||||
DoubleInt64Union union = new DoubleInt64Union();
|
DoubleLongUnion union = new DoubleLongUnion();
|
||||||
union.Long = value;
|
union.Long = value;
|
||||||
return union.Double;
|
return union.Double;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user