/// <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))); } }
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)); } } }
public override object CorrectArgument(object arg) { var org = (UFix)arg; return(UFix.FromDouble(1.0, org.Format.IntWidth, org.Format.FracWidth)); }