Example #1
0
 /// <summary>
 /// Tries to parse string into fixed point number.
 /// </summary>
 /// <returns><c>true</c>, if parse was tried, <c>false</c> otherwise.</returns>
 /// <param name="s">S.</param>
 /// <param name="result">Result.</param>
 public static bool TryParse(string s, out long result)
 {
     string[] NewValues = s.Split('.');
     if (NewValues.Length <= 2)
     {
         long Whole;
         if (long.TryParse(NewValues[0], out Whole))
         {
             if (NewValues.Length == 1)
             {
                 result = Whole << SHIFT_AMOUNT;
                 return(true);
             }
             else
             {
                 long Numerator;
                 if (long.TryParse(NewValues[1], out Numerator))
                 {
                     int  fractionDigits = NewValues[1].Length;
                     long Denominator    = 1;
                     for (int i = 0; i < fractionDigits; i++)
                     {
                         Denominator *= 10;
                     }
                     result = (Whole << SHIFT_AMOUNT) + FixedMath.Create(Numerator, Denominator);
                     return(true);
                 }
             }
         }
     }
     result = 0;
     return(false);
 }
Example #2
0
 public Vector2d(Vector3 vec)
 {
     this.x = FixedMath.Create(vec.x);
     this.y = FixedMath.Create(vec.z);
 }
Example #3
0
 public Vector2d(double xDoub, double yDoub)
 {
     this.x = FixedMath.Create(xDoub);
     this.y = FixedMath.Create(yDoub);
 }
Example #4
0
 public Vector2d(float xFloat, float yFloat)
 {
     this.x = FixedMath.Create(xFloat);
     this.y = FixedMath.Create(yFloat);
 }
Example #5
0
 public Vector2d(Vector2 vec2)
 {
     this.x = FixedMath.Create(vec2.x);
     this.y = FixedMath.Create(vec2.y);
 }
Example #6
0
 public long z; //Height
 public Vector3d(Vector3 vec3)
 {
     this.x = FixedMath.Create(vec3.x);
     this.y = FixedMath.Create(vec3.z);
     this.z = FixedMath.Create(vec3.y);
 }