示例#1
0
 /// <summary>
 /// Converts the format to a SysDOM type descriptor.
 /// </summary>
 public static TypeDescriptor ToType(this FixFormat fmt)
 {
     if (fmt.IsSigned)
     {
         return(TypeDescriptor.GetTypeOf(SFix.FromDouble(0.0, fmt.IntWidth, fmt.FracWidth)));
     }
     else
     {
         return(TypeDescriptor.GetTypeOf(UFix.FromDouble(0.0, fmt.IntWidth, fmt.FracWidth)));
     }
 }
示例#2
0
 public override object CreateInstance(ETypeCreationOptions options, object template)
 {
     if (options.HasFlag(ETypeCreationOptions.MultiplicativeNeutral))
     {
         if (template == null)
         {
             return(UFix.One);
         }
         else
         {
             var ufix = (UFix)template;
             return(UFix.FromDouble(1.0, ufix.Format.IntWidth, ufix.Format.FracWidth));
         }
     }
     else if (options.HasFlag(ETypeCreationOptions.NonZero))
     {
         if (template == null)
         {
             return(UFix.One);
         }
         else
         {
             var ufix = (UFix)template;
             return(UFix.FromUnsigned(Unsigned.FromUInt(1, ufix.Format.TotalWidth), ufix.Format.FracWidth));
         }
     }
     else
     {
         if (template == null)
         {
             return(UFix.Zero);
         }
         else
         {
             var ufix = (UFix)template;
             return(UFix.FromDouble(0.0, ufix.Format.IntWidth, ufix.Format.FracWidth));
         }
     }
 }
示例#3
0
        public override object CorrectArgument(object arg)
        {
            var org = (UFix)arg;

            return(UFix.FromDouble(1.0, org.Format.IntWidth, org.Format.FracWidth));
        }