diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2012-11-17 18:10:06 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-17 18:10:06 +0000 |
| commit | f68cfc5a0a8a07a2729636b1a1bedc41d2de738d (patch) | |
| tree | 40fc14f900b14e5db66b54ddf9b2e8bfb0035dae /cs-dotnet/src/gatsfloat.cs | |
| parent | 38f03bf3279c5e0351539777db52bb9f1a4bc614 (diff) | |
| download | libgats-f68cfc5a0a8a07a2729636b1a1bedc41d2de738d.tar.gz libgats-f68cfc5a0a8a07a2729636b1a1bedc41d2de738d.tar.bz2 libgats-f68cfc5a0a8a07a2729636b1a1bedc41d2de738d.tar.xz libgats-f68cfc5a0a8a07a2729636b1a1bedc41d2de738d.zip | |
Added XML standard in-code documentation, also GatsList and GatsDictionary
helpers.
Diffstat (limited to 'cs-dotnet/src/gatsfloat.cs')
| -rw-r--r-- | cs-dotnet/src/gatsfloat.cs | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/cs-dotnet/src/gatsfloat.cs b/cs-dotnet/src/gatsfloat.cs index 4709097..9763855 100644 --- a/cs-dotnet/src/gatsfloat.cs +++ b/cs-dotnet/src/gatsfloat.cs | |||
| @@ -10,6 +10,31 @@ using System; | |||
| 10 | 10 | ||
| 11 | namespace Com.Xagasoft.Gats | 11 | namespace Com.Xagasoft.Gats |
| 12 | { | 12 | { |
| 13 | /// <summary> | ||
| 14 | /// Encapsulates a single floating point value. | ||
| 15 | /// </summary> | ||
| 16 | /// <remarks> | ||
| 17 | /// The GATS floating point encoding is bit-exact with any standard | ||
| 18 | /// floating point encoding similar to the IEEE encoding. This means that | ||
| 19 | /// unlike textual encoding you will always get the exact same floating | ||
| 20 | /// point value back that you encoded. This format is arbitrary precision | ||
| 21 | /// and not dependant on platform or hardware. | ||
| 22 | /// | ||
| 23 | /// Although the format is arbitrary precision, the backend in C# uses a | ||
| 24 | /// double for maximum precision without resorting to a software arbitrary | ||
| 25 | /// precision library. | ||
| 26 | /// | ||
| 27 | /// Interestingly, unlike many other languages, C# provides a decimal type | ||
| 28 | /// that is also floating point, however the decimal type is encoded using | ||
| 29 | /// a bcd-like scheme. This makes it an excellent choice for many human | ||
| 30 | /// activities, but it cannot be encoded precisely as a GatsFloat. If you | ||
| 31 | /// would like to preserve the decimal nature of those types it may be | ||
| 32 | /// better to encode them as strings. | ||
| 33 | /// | ||
| 34 | /// In encoding, the GATS float uses two different type specifiers, an 'f' | ||
| 35 | /// indicates a normal floating point value. An 'F' represents a special | ||
| 36 | /// value: positive or negative NaN, infinity, or zero. | ||
| 37 | /// </remarks> | ||
| 13 | public class GatsFloat : GatsObject | 38 | public class GatsFloat : GatsObject |
| 14 | { | 39 | { |
| 15 | private static readonly double Log256 = Math.Log( 256.0 ); | 40 | private static readonly double Log256 = Math.Log( 256.0 ); |
| @@ -41,10 +66,10 @@ namespace Com.Xagasoft.Gats | |||
| 41 | { | 66 | { |
| 42 | case 'N': Value = -Double.NaN; break; | 67 | case 'N': Value = -Double.NaN; break; |
| 43 | case 'n': Value = Double.NaN; break; | 68 | case 'n': Value = Double.NaN; break; |
| 44 | case 'I': Value = Double.NegativeInfinity; break; | 69 | case 'I': Value = Double.NegativeInfinity; break; |
| 45 | case 'i': Value = Double.PositiveInfinity; break; | 70 | case 'i': Value = Double.PositiveInfinity; break; |
| 46 | case 'Z': Value = -0.0; break; | 71 | case 'Z': Value = -0.0; break; |
| 47 | case 'z': Value = 0.0; break; | 72 | case 'z': Value = 0.0; break; |
| 48 | } | 73 | } |
| 49 | } | 74 | } |
| 50 | else if( type == 'f' ) | 75 | else if( type == 'f' ) |
