aboutsummaryrefslogtreecommitdiff
path: root/cs-dotnet/src/gatsfloat.cs
diff options
context:
space:
mode:
Diffstat (limited to 'cs-dotnet/src/gatsfloat.cs')
-rw-r--r--cs-dotnet/src/gatsfloat.cs33
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
11namespace Com.Xagasoft.Gats 11namespace 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' )