コード例 #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(SFix.One);
         }
         else
         {
             var sfix = (SFix)template;
             return(SFix.FromDouble(1.0, sfix.Format.IntWidth, sfix.Format.FracWidth));
         }
     }
     else if (options.HasFlag(ETypeCreationOptions.NonZero))
     {
         if (template == null)
         {
             return(SFix.One);
         }
         else
         {
             var sfix = (SFix)template;
             return(SFix.FromSigned(Signed.FromInt(1, sfix.Format.TotalWidth), sfix.Format.FracWidth));
         }
     }
     else
     {
         if (template == null)
         {
             return(SFix.Zero);
         }
         else
         {
             var sfix = (SFix)template;
             return(SFix.FromDouble(0.0, sfix.Format.IntWidth, sfix.Format.FracWidth));
         }
     }
 }
コード例 #3
0
        public override object CorrectArgument(object arg)
        {
            var org = (SFix)arg;

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