예제 #1
0
        /// <summary>
        /// Returns the inverse hyperbolic cosine of the argument Value
        /// </summary>				
        public static ONReal acosh(ONReal value)
        {
            if (value == null)
                return ONReal.Null;

            return new ONReal(Convert.ToDecimal(Math.Log(Convert.ToDouble(value.TypedValue) + Math.Sqrt(Convert.ToDouble(value.TypedValue) * Convert.ToDouble(value.TypedValue) - 1))));
        }
예제 #2
0
        public override int CompareTo(object obj)
        {
            ONReal lVal = obj as ONReal;

            if (lVal == null)
            {
                return(1);
            }

            if (Value == null && lVal.Value == null)
            {
                return(0);
            }

            if (Value == null)
            {
                return(-1);
            }

            if (lVal.Value == null)
            {
                return(1);
            }

            return(TypedValue.CompareTo(lVal.TypedValue));
        }
예제 #3
0
        /// <summary>
        /// Returns the trigonometric arc tangent of the argument Value. The result is in the range of -PI/2 through PI/2
        /// </summary>		
        public static ONReal acot(ONReal value)
        {
            if (value == null)
                return ONReal.Null;

            return new ONReal(Convert.ToDecimal(Math.PI / 2 - Math.Atan(Convert.ToDouble(value.TypedValue))));
        }
예제 #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="val">Value for this type</param>
 public ONReal(ONReal val)
 {
     if (val == null)
         Value = null;
     else
         Value = val.Value;
 }
예제 #5
0
        /// <summary>
        /// Creates XML elements from the data of the system.
        /// </summary>
        /// <param name="xmlWriter">Object with the XML message to add new information and return to client side</param>
        /// <param name="val">Value to be puted inside the XML message</param>
        /// <param name="dtdVersion">Version of the DTD that follows the XML message</param>
        /// <param name="xmlElement">Element of the XML that is checked</param>
        public static void ON2XML(XmlWriter xmlWriter, ONReal val, double dtdVersion, string xmlElement)
        {
            if (val == null)
            {
                if (xmlElement == ONXml.XMLTAG_V)
                    xmlWriter.WriteElementString(xmlElement, "");
                else
                    xmlWriter.WriteElementString(ONXml.XMLTAG_NULL, null);
            }
            else
            {
                if (dtdVersion < 2.0) // Apply the locale format
                    xmlWriter.WriteElementString(xmlElement, val.TypedValue.ToString("0.##############"));
                else
                {
                    xmlWriter.WriteStartElement(xmlElement);
                    if (xmlElement == ONXml.XMLTAG_OIDFIELD && dtdVersion > 2.0)
                        xmlWriter.WriteAttributeString("Type", "real");

                    string lValue = Pack(val);
                    xmlWriter.WriteString(lValue);
                    xmlWriter.WriteEndElement();
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Returns the absolute value of the specified argument
        /// </summary>				
        public static ONReal absReal(ONReal value)
        {
            if (value == null)
                return ONReal.Null;

            return new ONReal(Math.Abs(value.TypedValue));
        }
예제 #7
0
        /// <summary>
        /// Returns the inverse hyperbolic cotangent of the argument Value
        /// </summary>			
        public static ONReal acoth(ONReal value)
        {
            if (value == null)
                return ONReal.Null;

            return new ONReal(Convert.ToDecimal(Math.Log((Convert.ToDouble(value.TypedValue) + 1) / (Convert.ToDouble(value.TypedValue) - 1)) / 2));
        }
예제 #8
0
        public static ONReal Exp(ONReal obj1)
        {
            if (((object)obj1 == null) || (obj1.Value == null))
            {
                throw new ONNullException(null);
            }

            return(new ONReal(Convert.ToDecimal(Math.Exp(Convert.ToDouble(obj1.TypedValue)))));
        }
예제 #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="val">Value for this type</param>
 public ONReal(ONReal val)
 {
     if (val == null)
     {
         Value = null;
     }
     else
     {
         Value = val.Value;
     }
 }
예제 #10
0
        /// <summary>
        /// Checks the format of the data previously to be included in the XML message
        /// </summary>
        /// <param name="val">Contains the data to be checked</param>
        public static string Pack(ONReal val)
        {
            if (val.TypedValue == 0)
                return "0";
            else
            {
                //Convert the value in a string with scientific format.
                string lValue = val.TypedValue.ToString("0.0#############E-0").Replace(",", ".");

                return lValue;
            }
        }
예제 #11
0
        public static ONReal Min(ONReal obj1, ONNat obj2)
        {
            if (((object)obj1 == null) || ((object)obj2 == null))
            {
                throw new ONNullException(null);
            }

            if ((obj1.Value == null) || (obj2.Value == null))
            {
                return(ONReal.Null);
            }

            return(new ONReal(Math.Min(obj1.TypedValue, obj2.TypedValue)));
        }
예제 #12
0
        public static ONReal Pow(ONReal obj1, ONNat obj2)
        {
            if (((object)obj1 == null) || ((object)obj2 == null))
            {
                throw new ONNullException(null);
            }

            if ((obj1.Value == null) || (obj2.Value == null))
            {
                return(ONReal.Null);
            }

            return(new ONReal(Convert.ToDecimal(Math.Pow(Convert.ToDouble(obj1.TypedValue), Convert.ToDouble(obj2.TypedValue)))));
        }
예제 #13
0
        public static ONInt Divint(ONReal obj1, ONReal obj2)
        {
            if (((object)obj1 == null) || ((object)obj2 == null))
            {
                throw new ONNullException(null);
            }

            if ((obj1.Value == null) || (obj2.Value == null))
            {
                return(ONInt.Null);
            }

            decimal lReturn = Convert.ToDecimal(obj1.TypedValue / obj2.TypedValue);

            lReturn = decimal.Truncate(lReturn);
            return(new ONInt(Convert.ToInt32(lReturn)));
        }
예제 #14
0
        /// <summary>
        /// Converts an angle measured in radians (Value) in an angle measured in degrees. The result is mathematically equivalent to Value * 180 / PI
        /// </summary>				
        public static ONReal toDegrees(ONReal value)
        {
            if (value == null)
                return ONReal.Null;

            return new ONReal(value.TypedValue * 180 / Convert.ToDecimal(Math.PI));
        }
예제 #15
0
        /// <summary>
        /// Returns the trigonometric arc tangent of the argument Value. The result is in the range of -PI through PI
        /// </summary>			
        public static ONReal atan2(ONReal x, ONReal y)
        {
            if (x == null || y == null)
                return ONReal.Null;

            decimal lX = x.TypedValue;
            decimal lY = y.TypedValue;

            if (lX == 0)
                return new ONReal(Convert.ToDecimal(Math.Sign(lY) * 1.5707963267949));
            else if (lX > 0)
                return new ONReal(Convert.ToDecimal(Math.Atan(Convert.ToDouble(lY / lX))));
            else
                return new ONReal(Convert.ToDecimal(Math.Atan(Convert.ToDouble(lY / lX)) + 3.14159265358979 * Math.Sign(lY)));
        }
예제 #16
0
        /// <summary>
        /// Converts an angle measured in degrees (Value) in an angle measured in radians. The result is mathematically equivalent to Value * PI / 180
        /// </summary>			
        public static ONReal toRadians(ONReal value)
        {
            if (value == null)
                return ONReal.Null;

            return new ONReal(value.TypedValue * Convert.ToDecimal(Math.PI) / 180);
        }
예제 #17
0
        /// <summary>
        /// Returns the inverse hyperbolic cosecant of the argument Value
        /// </summary>			
        public static ONReal acsech(ONReal value)
        {
            if (value == null)
                return ONReal.Null;

            return new ONReal(Convert.ToDecimal(Math.Log((Math.Sign(value.TypedValue) * Math.Sqrt(Convert.ToDouble(value.TypedValue) * Convert.ToDouble(value.TypedValue) + 1) + 1) / Convert.ToDouble(value.TypedValue))));
        }
예제 #18
0
        /// <summary>
        /// Returns the Euler constant raised to the specified argument, e^Value
        /// </summary>		
        public static ONReal exp(ONReal value)
        {
            if (value == null)
                return ONReal.Null;

            return new ONReal(Convert.ToDecimal(Math.Exp(Convert.ToDouble(value.TypedValue))));
        }
예제 #19
0
        /// <summary>
        /// Returns the sign of the specified argument, represented as -1, 0 and 1, in correspondence with negative, zero or positive argument value
        /// </summary>			
        public static ONInt sign(ONReal value)
        {
            if (value == null)
                return ONInt.Null;

            return new ONInt(Math.Sign(value.TypedValue));
        }
예제 #20
0
        /// <summary>
        /// Returns the integer value closest to Value
        /// </summary>			
        public static ONInt round(ONReal value)
        {
            if (value == null)
                return ONInt.Null;

            int lTemp = Convert.ToInt32(Math.Round(value.TypedValue));

            if (value.TypedValue - lTemp == 0.5m)
                lTemp++;

                return new ONInt(lTemp);
        }
예제 #21
0
        public static ONReal Min(ONInt obj1, ONReal obj2)
        {
            if (((object) obj1 == null) || ((object) obj2 == null))
                throw new ONNullException(null);

            if ((obj1.Value == null) || (obj2.Value == null))
                return ONReal.Null;

            return new ONReal(Math.Min(obj1.TypedValue, obj2.TypedValue));
        }
예제 #22
0
        /// <summary>
        /// Returns the integer part of the real argument Value just removing the fractionary part.
        /// If Value is below 0, it returns the ceiling, otherwise it returns the floor
        /// </summary>				
        public static ONInt trunc(ONReal value)
        {
            if (value == null)
                return ONInt.Null;

            return new ONInt(Convert.ToInt32(Decimal.Truncate(value.TypedValue)));
        }
예제 #23
0
        /// <summary>
        /// Returns the inverse hyperbolic tangent of the argument Value
        /// </summary>		
        public static ONReal atanh(ONReal value)
        {
            if (value == null)
                return ONReal.Null;

            return new ONReal(Convert.ToDecimal(Math.Log((1 + Convert.ToDouble(value.TypedValue)) / (1 - Convert.ToDouble(value.TypedValue)))) / 2);
        }
예제 #24
0
        /// <summary>
        /// Returns the trigonometric tangent of the argument Angle
        /// </summary>			
        public static ONReal cot(ONReal angle)
        {
            if (angle == null)
                return ONReal.Null;

            return new ONReal(Convert.ToDecimal(1 / Math.Tan(Convert.ToDouble(angle.TypedValue))));
        }
예제 #25
0
        /// <summary>
        /// Returns the largest value (closest to positive infinity) less than or equal 
        /// to Value, and mathematically equal to an integer
        /// </summary>			
        public static ONInt floor(ONReal value)
        {
            if (value == null)
                return ONInt.Null;

            return new ONInt(Convert.ToInt32(Math.Floor(Convert.ToDouble(value.TypedValue))));
        }
예제 #26
0
        public static ONReal Exp(ONReal obj1)
        {
            if (((object) obj1 == null) || (obj1.Value == null))
                throw new ONNullException(null);

            return new ONReal(Convert.ToDecimal(Math.Exp(Convert.ToDouble(obj1.TypedValue))));
        }
예제 #27
0
        /// <summary>
        /// Returns the minimum between Value1 and Value2
        /// </summary>				
        public static ONReal minimum(ONReal value1, ONReal value2)
        {
            if (value1 == null || value2 == null)
                return ONReal.Null;

            return new ONReal(Math.Min(value1.TypedValue, value2.TypedValue));
        }
예제 #28
0
        /// <summary>
        /// Returns the value Base ^ Exponent
        /// </summary>				
        public static ONReal pow(ONReal Base, ONReal Exponent)
        {
            if (Base == null || Exponent == null)
                return ONReal.Null;

            return new ONReal(Convert.ToDecimal(Math.Pow(Convert.ToDouble(Base.TypedValue), Convert.ToDouble(Exponent.TypedValue))));
        }
예제 #29
0
        /// <summary>
        /// Returns the number with the specified precision nearest the specified value, 
        /// where digits is the number of significant fractional digits (precision) in 
        /// the return value
        /// </summary>			
        public static ONReal roundEx(ONReal value, ONInt digits)
        {
            if (value == null || digits == null)
                return ONReal.Null;

            decimal lvalue;
            int ldigits;

            lvalue = value.TypedValue;
            ldigits = digits.TypedValue;

            return new ONReal((decimal)(Math.Round(lvalue, ldigits, MidpointRounding.AwayFromZero)));
        }
예제 #30
0
        /// <summary>
        /// Returns the string representation of Value
        /// </summary>		
        public static ONString realToStr(ONReal value)
        {
            if (value == null)
                return ONString.Null;

            string lTemp = Convert.ToString(value.TypedValue);
            lTemp = lTemp.Replace(",", ".");
            return new ONString(lTemp);
        }
예제 #31
0
        /// <summary>
        /// Returns the logarithm of Value, in base Base
        /// </summary>			
        public static ONReal logBase(ONReal value, ONReal Base)
        {
            if (value == null || Base == null)
                return ONReal.Null;

            return new ONReal(Convert.ToDecimal(Math.Log(Convert.ToDouble(value.TypedValue), Convert.ToDouble(Base.TypedValue))));
        }
예제 #32
0
        /// <summary>
        /// Returns the trigonometric cosecant of the argument Value
        /// </summary>				
        public static ONReal csec(ONReal value)
        {
            if (value == null)
                return ONReal.Null;

            return new ONReal(Convert.ToDecimal(1 / Math.Sin(Convert.ToDouble(value.TypedValue))));
        }
예제 #33
0
        public static ONInt Divint(ONReal obj1, ONReal obj2)
        {
            if (((object) obj1 == null) || ((object) obj2 == null))
                throw new ONNullException(null);

            if ((obj1.Value == null) || (obj2.Value == null))
                return ONInt.Null;

            decimal lReturn = Convert.ToDecimal(obj1.TypedValue / obj2.TypedValue) ;
            lReturn = decimal.Truncate(lReturn);
            return new ONInt(Convert.ToInt32(lReturn));
        }
예제 #34
0
        /// <summary>
        /// Returns the trigonometric inverse cosecant of the argument Value
        /// </summary>		
        public static ONReal acsec(ONReal value)
        {
            if (value == null)
                return ONReal.Null;

            return new ONReal(Convert.ToDecimal(Math.Atan(Math.Sign(value.TypedValue) / Math.Sqrt(Convert.ToDouble(value.TypedValue) * Convert.ToDouble(value.TypedValue) - 1))));
        }
예제 #35
0
        public static ONReal Pow(ONInt obj1, ONReal obj2)
        {
            if (((object) obj1 == null) || ((object) obj2 == null))
                throw new ONNullException(null);

            if ((obj1.Value == null) || (obj2.Value == null))
                return ONReal.Null;

            return new ONReal(Convert.ToDecimal(Math.Pow(obj1.TypedValue, Convert.ToDouble(obj2.TypedValue))));
        }
예제 #36
0
        /// <summary>
        /// Returns a uniformly distributed pseudo-random (real) number greater than or equal 
        /// to LowerBound and less than UpperBound
        /// </summary>			
        public static ONReal rndRealBound(ONReal lowerBound, ONReal upperBound)
        {
            if (lowerBound == null || upperBound == null)
                return ONReal.Null;

            return new ONReal(Convert.ToDecimal((new Random()).NextDouble()) * (upperBound.TypedValue - lowerBound.TypedValue) + lowerBound.TypedValue);
        }