public static NumberType GetTypeCode(Type type) { if (typecode == null) { typecode = new Dictionary <Type, NumberType>(); //typecode[null] = 0; typecode[typeof(bool)] = NumberType.BOOL; typecode[typeof(sbyte)] = NumberType.SBYTE; typecode[typeof(byte)] = NumberType.BYTE; typecode[typeof(Int16)] = NumberType.INT16; typecode[typeof(UInt16)] = NumberType.UINT16; typecode[typeof(Int32)] = NumberType.INT32; typecode[typeof(UInt32)] = NumberType.UINT32; typecode[typeof(Int64)] = NumberType.INT64; typecode[typeof(UInt64)] = NumberType.UINT64; typecode[typeof(float)] = NumberType.FLOAT; typecode[typeof(double)] = NumberType.DOUBLE; typecode[typeof(IntPtr)] = NumberType.INTPTR; typecode[typeof(UIntPtr)] = NumberType.UINTPTR; typecode[typeof(decimal)] = NumberType.DECIMAL; typecode[typeof(char)] = NumberType.CHAR; } if (type.IsEnum) { return(NumberType.ENUM); } NumberType t = NumberType.IsNotNumber; typecode.TryGetValue(type, out t); return(t); }
private static void ImportSSL() { Dictionary <string, double> dict = new Dictionary <string, double>(11); dict.Add("D1|前一|10", 1.0 / 10.0); dict.Add("D2|二位|0", 1.0 / 10.0); dict.Add("D3|后一|10", 1.0 / 10.0); dict.Add("P2|前二直选|98", 1.0 / 100.0); dict.Add("C2|前二组选|0", 1.0 / 50.0); dict.Add("P3|直选三|980", 1.0 / 1000.0); dict.Add("C33|组选三|320", (3.0 / 1000.0)); dict.Add("C36|组选六|160", (6.0 / 1000.0)); foreach (var kp in dict) { string[] arr = kp.Key.Split('|'); NumberType nt = new NumberType(); nt.Name = arr[1]; nt.Code = arr[0]; nt.RuleType = "SSL"; nt.Probability = kp.Value; nt.Amount = 2.0; nt.Prize = double.Parse(arr[2]); nt.Length = GetLength(arr[0]); NumberTypeBiz.Instance.Add(nt); } }
//public static IBox Convert(IBox box, NumberType type) //{ // switch (type) // { // case NumberType.BOOL: // case NumberType.SBYTE: // case NumberType.BYTE: // case NumberType.CHAR: // case NumberType.INT16: // case NumberType.UINT16: // case NumberType.INT32: // case NumberType.UINT32: // { // if (box is BoxInt32) return box; // BoxInt32 v32 = ValueOnStack.Make(type) as BoxInt32; // BoxInt64 b64 = box as BoxInt64; // BoxDouble bdb = box as BoxDouble; // if (b64 != null) // v32.value = (int)b64.value; // else // v32.value = (int)bdb.value; // return v32; // } // case NumberType.INT64: // case NumberType.UINT64: // { // if (box is BoxInt64) return box; // BoxInt64 v64 = ValueOnStack.Make(type) as BoxInt64; // BoxInt32 b32 = box as BoxInt32; // BoxDouble bdb = box as BoxDouble; // if (b32 != null) // v64.value = b32.value; // else // v64.value = (Int64)bdb.value; // return v64; // } // case NumberType.FLOAT: // case NumberType.DOUBLE: // { // if (box is BoxDouble) return box; // BoxDouble vdb = new BoxDouble(type); // BoxInt32 b32 = box as BoxInt32; // BoxInt64 b64 = box as BoxInt64; // if (b32 != null) // vdb.value = b32.value; // else // vdb.value = b64.value; // return vdb; // } // default: // return null; // } //} public static VBox Convert(VBox box, NumberType type) { VBox b = MakeVBox(type); b.Set(box); return(b); }
private static void setFieldValues(NumberType numberType, HashMap <String, Field> numericFieldMap) { /*Number*/ object number = GetNumberType(numberType, NumericType.DOUBLE .ToString()); numericFieldMap[NumericType.DOUBLE.ToString()].SetDoubleValue(Convert.ToDouble( number)); number = GetNumberType(numberType, NumericType.INT32.ToString()); numericFieldMap[NumericType.INT32.ToString()].SetInt32Value(Convert.ToInt32( number)); number = GetNumberType(numberType, NumericType.INT64.ToString()); numericFieldMap[NumericType.INT64.ToString()].SetInt64Value(Convert.ToInt64( number)); number = GetNumberType(numberType, NumericType.SINGLE.ToString()); numericFieldMap[NumericType.SINGLE.ToString()].SetSingleValue(Convert.ToSingle( number)); number = GetNumberType(numberType, DATE_FIELD_NAME); numericFieldMap[DATE_FIELD_NAME].SetInt64Value(Convert.ToInt64(number)); }
private static void Import12X3() { Dictionary <string, double> dict = new Dictionary <string, double>(11); dict.Add("D1|前一|110", 1.0 / 12.0); dict.Add("D2|二位|0", 1.0 / 12.0); dict.Add("D3|三位|0", 1.0 / 12.0); dict.Add("P2|前二直选|5000", 1.0 / 132.0); dict.Add("C2|前二组选|3344", 1.0 / 66.0); dict.Add("P3|前三直选|50000", 1.0 / 1320.0); dict.Add("C3|前三组选|27774", 1.0 / 220.0); dict.Add("G2|过二关|10000", 1.0 / 144.0); dict.Add("G3|过三关|500000", 1.0 / 1728.0); dict.Add("Z2|过二关组选|0", 2.0 / 144.0); dict.Add("Z33|过三关组选三|0", 3.0 / 1728.0); dict.Add("Z36|过三关组选六|0", 6.0 / 1728.0); foreach (var kp in dict) { string[] arr = kp.Key.Split('|'); NumberType nt = new NumberType(); nt.Name = arr[1]; nt.Code = arr[0]; nt.RuleType = "12X3"; nt.Probability = kp.Value; nt.Amount = 2.0; nt.Prize = double.Parse(arr[2]); nt.Length = GetLength(arr[0]); NumberTypeBiz.Instance.Add(nt); } }
private static void Import11x5() { Dictionary <string, double> dict = new Dictionary <string, double>(11); //dict.Add("D1|前一|13", 1.0 / 11.0); //dict.Add("D2|二位|0", 1.0 / 11.0); //dict.Add("D3|三位|0", 1.0 / 11.0); //dict.Add("D4|四位|0", 1.0 / 11.0); //dict.Add("D5|五位|0", 1.0 / 11.0); //dict.Add("P2|前二直选|130", 1.0 / 110.0); //dict.Add("C2|前二组选|65", 1.0 / 55.0); //dict.Add("P3|前三直选|1170", 1.0 / 990.0); //dict.Add("C3|前三组选|195", 1.0 / 165.0); //dict.Add("C5|任五|540", 1.0 / 462.0); dict.Add("A2|任二|6", 1.0 / 5.5); dict.Add("A3|任三|19", 1.0 / 16.5); dict.Add("A4|任四|78", 1.0 / 66.0); dict.Add("A6|任六|90", 1.0 / 77.0); dict.Add("A7|任七|26", 1.0 / 22.0); dict.Add("A8|任八|9", 1.0 / 8.25); foreach (var kp in dict) { string[] arr = kp.Key.Split('|'); NumberType nt = new NumberType(); nt.Name = arr[1]; nt.Code = arr[0]; nt.RuleType = "11X5"; nt.Probability = kp.Value; nt.Amount = 2.0; nt.Prize = double.Parse(arr[2]); nt.Length = GetLength(arr[0]); NumberTypeBiz.Instance.Add(nt); } }
public static void Import11x5() { Dictionary<string, double> dict = new Dictionary<string, double>(11); //dict.Add("D1|前一|13", 1.0 / 11.0); //dict.Add("D2|二位|0", 1.0 / 11.0); //dict.Add("D3|三位|0", 1.0 / 11.0); //dict.Add("D4|四位|0", 1.0 / 11.0); //dict.Add("D5|五位|0", 1.0 / 11.0); //dict.Add("P2|前二直选|130", 1.0 / 110.0); //dict.Add("C2|前二组选|65", 1.0 / 55.0); //dict.Add("P3|前三直选|1170", 1.0 / 990.0); //dict.Add("C3|前三组选|195", 1.0 / 165.0); //dict.Add("C5|任五|540", 1.0 / 462.0); dict.Add("A1|任一|13", 5.0 / 11.0); // dict.Add("A2|任二|6", 1.0 / 5.5); // dict.Add("A3|任三|19", 1.0 / 16.5); // dict.Add("A4|任四|78", 1.0 / 66.0); // dict.Add("A6|任六|90", 1.0 / 77.0); // dict.Add("A7|任七|26", 1.0 / 22.0); // dict.Add("A8|任八|9", 1.0 / 8.25); foreach (var kp in dict) { string[] arr = kp.Key.Split('|'); NumberType nt = new NumberType(); nt.Name = arr[1]; nt.Code = arr[0]; nt.RuleType = "11X5"; nt.Probability = kp.Value; nt.Amount = 2.0; nt.Prize = double.Parse(arr[2]); nt.Length = GetLength(arr[0]); NumberTypeBiz.Instance.Add(nt); } }
private void AddImage(NumberType numberType, int columnIndex) { var image = GetCroppedBitmap(numberType); Children.Add(image); SetColumn(image, columnIndex); }
public override EvalType Evaluate(EvalContext context) { NumberType[] n = new NumberType[Parameters.Length]; for (int i = 0; i < n.Length; i++) n[i] = NT(Parameters[i].Evaluate(context)); return new NumberListType(n); }
private void TestHashTransformHelper <T>(T[] data, uint[] results, NumberType type) { var builder = new ArrayDataViewBuilder(Env); builder.AddColumn("F1", type, data); var srcView = builder.GetDataView(); HashTransform.Column col = new HashTransform.Column(); col.Source = "F1"; col.HashBits = 5; col.Seed = 42; HashTransform.Arguments args = new HashTransform.Arguments(); args.Column = new HashTransform.Column[] { col }; var hashTransform = new HashTransform(Env, args, srcView); using (var cursor = hashTransform.GetRowCursor(c => true)) { var resultGetter = cursor.GetGetter <uint>(1); uint resultRow = 0; foreach (var r in results) { Assert.True(cursor.MoveNext()); resultGetter(ref resultRow); Assert.True(resultRow == r); } } }
private void BaseConverterControl_Loaded(object sender, RoutedEventArgs e) { // The Loaded event will be raised again whenever the tool window tab is changed, // so we must make sure this event handler isn't called again. // http://www.hardcodet.net/2008/01/wpf-loaded-event-fired-repeatedly this.Loaded -= this.BaseConverterControl_Loaded; Options options = this.PackageOptions; if (options != null) { this.CurrentByteOrder = options.BaseConverterByteOrder; this.CurrentNumberType = options.BaseConverterNumberType; // Any time the options are applied (even if they didn't change), update the text boxes. // This is cheaper/easier than doing a bunch of work to figure out which options changed. options.Applied += (s, a) => { if (this.IsLoaded) { this.UpdateFromCurrentTextBox(); } }; } else { // The associated window's package should have been set by now. throw new InvalidOperationException("The base converter control can't be loaded without its associated options."); } }
private static bool TryTextToNumber(string text, NumberType type, out object?val) { try { val = type switch { NumberType.Byte => byte.Parse(text, CultureInfo.InvariantCulture), NumberType.SByte => sbyte.Parse(text, CultureInfo.InvariantCulture), NumberType.UShort => ushort.Parse(text, CultureInfo.InvariantCulture), NumberType.Short => short.Parse(text, CultureInfo.InvariantCulture), NumberType.UInt => uint.Parse(text, CultureInfo.InvariantCulture), NumberType.Int => int.Parse(text, CultureInfo.InvariantCulture), NumberType.ULong => ulong.Parse(text, CultureInfo.InvariantCulture), NumberType.Long => long.Parse(text, CultureInfo.InvariantCulture), NumberType.Float => float.Parse(text, CultureInfo.InvariantCulture), NumberType.Double => double.Parse(text, CultureInfo.InvariantCulture), NumberType.Decimal => decimal.Parse(text, CultureInfo.InvariantCulture), _ => throw new ArgumentOutOfRangeException(), }; return(true); } catch (FormatException) { val = null; return(false); } }
public void assertOpenRangeQuery(NumberType boundType, String @operator, int expectedDocCount) { StringBuilder sb = new StringBuilder(); foreach (FieldType.NumericType type in Enum.GetValues(typeof(FieldType.NumericType))) { String boundStr = NumberToString(GetNumberType(boundType, type.ToString())); sb.append("+").append(type.ToString()).append(@operator).append('"').append(boundStr).append('"').append(' '); } //String boundDateStr = ESCAPER.Escape( // DATE_FORMAT.format(new Date(getNumberType(boundType, DATE_FIELD_NAME) // .longValue())), LOCALE, EscapeQuerySyntax.Type.STRING).toString(); string boundDateStr = ESCAPER.Escape( DATE_FORMAT.Format(Convert.ToInt64(GetNumberType(boundType, DATE_FIELD_NAME))), LOCALE, EscapeQuerySyntax.Type.STRING).toString(); sb.append("+").append(DATE_FIELD_NAME).append(@operator).append('"').append(boundDateStr).append('"'); TestQuery(sb.toString(), expectedDocCount); }
/// <summary> /// Restituisce la Parte Intera o quella Decimale di un numero /// </summary> /// <param name="numero">Numero che si vuole formattare</param> /// <param name="tipo">Indica la parte intera o decimale</param> /// <returns>- Stringa - Restituisce la Parte Intera o quella Decimale di un numero</returns> public static string GetTypeNumber(object numero, NumberType tipo) { if (System.Double.IsNaN(System.Double.Parse(numero.ToString()))) { return(""); } char[] del = ",".ToCharArray(); string[] num = numero.ToString().Split(del); if (num.Length > 1) { if (tipo == NumberType.Intero) { return(num[0]); } else { return(num[1]); } } else { if (tipo == NumberType.Intero) { return(num[0]); } else { return("00"); } } }
public NumberMappingDescriptor <T> Type(NumberType type) { var stringType = Enum.GetName(typeof(NumberType), type); this._Mapping.Type = stringType; return(this); }
public void SetNumber(int num, NumberType type = NumberType.Normal) { if (num == 0 && type != NumberType.Countdown) { ShowMessage.text = ""; return; } var color = default(Color); if (type == NumberType.White) { color = GlobalState.NormalColor; } else if (type == NumberType.Countdown) { color = GlobalState.BlueColor; if (num >= 0) { transform.localPosition += new Vector3(0.15f, 0, 0); } } else { color = num > 0 ? GlobalState.GreenColor : GlobalState.RedColor; } ShowMessage.color = color; ShowMessage.text = (type != NumberType.Countdown && num >= 0) ? "+" : ""; ShowMessage.text += num.ToString(); }
private static object GetConvertedValueForBytes(byte[] machineValueBytes, NumberType dataType) { object convertedValue = null; if (machineValueBytes != null) { switch (dataType) { case NumberType.Byte: convertedValue = machineValueBytes[0]; break; case NumberType.Decimal: convertedValue = ToDecimal(machineValueBytes); break; case NumberType.Double: convertedValue = BitConverter.ToDouble(machineValueBytes, 0); break; case NumberType.Int32: convertedValue = BitConverter.ToInt32(machineValueBytes, 0); break; case NumberType.Int64: convertedValue = BitConverter.ToInt64(machineValueBytes, 0); break; case NumberType.Int16: convertedValue = BitConverter.ToInt16(machineValueBytes, 0); break; case NumberType.SByte: unchecked { convertedValue = (sbyte)machineValueBytes[0]; } break; case NumberType.Single: convertedValue = BitConverter.ToSingle(machineValueBytes, 0); break; case NumberType.UInt32: convertedValue = BitConverter.ToUInt32(machineValueBytes, 0); break; case NumberType.UInt64: convertedValue = BitConverter.ToUInt64(machineValueBytes, 0); break; case NumberType.UInt16: convertedValue = BitConverter.ToUInt16(machineValueBytes, 0); break; } } return(convertedValue); }
public static VBox Convert(VBox box, NumberType type) { VBox vBox = ValueOnStack.MakeVBox(type); vBox.Set(box); return(vBox); }
private static int GetNumBytesForNumberType(NumberType numberType) { int result = 0; switch (numberType) { case NumberType.Byte: case NumberType.SByte: result = sizeof(byte); break; case NumberType.Int16: case NumberType.UInt16: result = sizeof(short); break; case NumberType.Int32: case NumberType.UInt32: case NumberType.Single: result = sizeof(int); break; case NumberType.Double: case NumberType.Int64: case NumberType.UInt64: result = sizeof(double); break; case NumberType.Decimal: result = sizeof(decimal); break; } return(result); }
private void TestHashTransformVectorHelper <T>(T[][] data, uint[][] results, NumberType type) { var builder = new ArrayDataViewBuilder(Env); builder.AddColumn("F1V", type, data); TestHashTransformVectorHelper(builder, results); }
private static void Import11x5() { Dictionary<string, double> dict = new Dictionary<string, double>(11); dict.Add("D1|前一|13", 1.0 / 11.0); dict.Add("D2|二位|0", 1.0 / 11.0); dict.Add("D3|三位|0", 1.0 / 11.0); dict.Add("D4|四位|0", 1.0 / 11.0); dict.Add("D5|五位|0", 1.0 / 11.0); dict.Add("P2|前二直选|130", 1.0 / 110.0); dict.Add("C2|前二组选|65", 1.0 / 55.0); dict.Add("P3|前三直选|1170", 1.0 / 990.0); dict.Add("C3|前三组选|195", 1.0 / 165.0); dict.Add("P4|前四直选|78", 1.0 / 7920.0); dict.Add("C4|前四组选|78", 1.0 / 330.0); dict.Add("P5|前五直选|540", 1.0 / 55440.0); dict.Add("C5|任五|540", 1.0 / 462.0); foreach (var kp in dict) { string[] arr = kp.Key.Split('|'); NumberType nt = new NumberType(); nt.Name = arr[1]; nt.Code = arr[0]; nt.RuleType = "11X5"; nt.Probability = kp.Value; nt.Amount = 2.0; nt.Prize = double.Parse(arr[2]); nt.Length = GetLength(arr[0]); NumberTypeBiz.Instance.Add(nt); } }
public void assertSimpleQuery(NumberType numberType, int expectedDocCount) { StringBuilder sb = new StringBuilder(); foreach (FieldType.NumericType type in Enum.GetValues(typeof(FieldType.NumericType))) { String numberStr = NumberToString(GetNumberType(numberType, type.ToString())); sb.append('+').append(type.ToString()).append(":\"").append(numberStr) .append("\" "); } //String dateStr = ESCAPER.Escape( // DATE_FORMAT.format(new DateTime(getNumberType(numberType, DATE_FIELD_NAME) // .longValue())), LOCALE, EscapeQuerySyntax.Type.STRING).toString(); string dateStr = ESCAPER.Escape( DATE_FORMAT.Format(Convert.ToInt64(GetNumberType(numberType, DATE_FIELD_NAME))), LOCALE, EscapeQuerySyntax.Type.STRING).toString(); sb.append('+').append(DATE_FIELD_NAME).append(":\"").append(dateStr) .append('"'); TestQuery(sb.toString(), expectedDocCount); }
public OneNumberOperationModel(String identifier, int number, String hintKeyword, NumberType numberType) { Identifier = identifier; Number = number; HintKeyword = hintKeyword; MyNumberType = numberType; }
public NumberMappingDescriptor <T> Type(NumberType type) { var stringType = type.GetStringValue(); this._Mapping.Type = stringType; return(this); }
public override void SetXElement(XElement xEdit) { Identifier = xEdit.Name.ToString(); if (xEdit.Attribute("number") != null && !xEdit.Attribute("number").Value.ToString().Equals(String.Empty)) { String multiple = xEdit.Attribute("number").Value; if (int.TryParse(multiple, out int iNumber)) { Number = iNumber; } } if (xEdit.Name.ToString().Equals("SetStartTime")) { MyNumberType = NumberType.OTHER; } else if (xEdit.Name.ToString().Equals("FillColor")) { MyNumberType = NumberType.COLOR; } else if (xEdit.Name.ToString().Equals("SetAllTime")) { MyNumberType = NumberType.OTHER; } else if (xEdit.Name.ToString().Equals("MatchTotalTimeLattice")) { MyNumberType = NumberType.OTHER; } else if (xEdit.Name.ToString().Equals("Animation.Windmill")) { MyNumberType = NumberType.OTHER; } HintKeyword = xEdit.Attribute("hintKeyword").Value; }
public TensorConfig(DeviceType devicetype, NumberType datatype) { Device = new Device(); Device.Type = devicetype; Device.ID = 0; NumType = datatype; }
private string DoWork(string[] content) { if (content.Length < 3) { return(Resources.LocalResource.Error_Empy_File); } StringBuilder message = new StringBuilder(); string[] rowOne = content[0].Split(' '); string[] rowTwo = content[1].Split(' '); string[] rowThree = content[2].Split(' '); if (!ValidateLengthAllRows(rowOne, rowTwo, rowThree, message)) { return(message.ToString()); } for (int i = 0; i < rowOne.Length; i++) { string[,] matrix = new string[MATRIX_ROWS, MATRIX_COLUMNS]; ValidateAndFillRowMatrix(rowOne[i].ToCharArray(), matrix, 0, message); ValidateAndFillRowMatrix(rowTwo[i].ToCharArray(), matrix, 1, message); ValidateAndFillRowMatrix(rowThree[i].ToCharArray(), matrix, 2, message); NumberType numberType = new NumberType(matrix); if (message.ToString().Contains("Error")) { return(string.Format(message.ToString(), i + 1)); } message.Append(DecodeNumber(numberType)); } return(message.ToString()); }
private static void setFieldValues(NumberType numberType, HashMap <String, Field> numericFieldMap) { /*Number*/ object number = GetNumberType(numberType, FieldType.NumericType.DOUBLE .ToString()); numericFieldMap[FieldType.NumericType.DOUBLE.ToString()].DoubleValue = Convert.ToDouble( number); number = GetNumberType(numberType, FieldType.NumericType.INT.ToString()); numericFieldMap[FieldType.NumericType.INT.ToString()].IntValue = Convert.ToInt32( number); number = GetNumberType(numberType, FieldType.NumericType.LONG.ToString()); numericFieldMap[FieldType.NumericType.LONG.ToString()].LongValue = Convert.ToInt64( number); number = GetNumberType(numberType, FieldType.NumericType.FLOAT.ToString()); numericFieldMap[FieldType.NumericType.FLOAT.ToString()].FloatValue = Convert.ToSingle( number); number = GetNumberType(numberType, DATE_FIELD_NAME); numericFieldMap[DATE_FIELD_NAME].LongValue = Convert.ToInt64(number); }
private static decimal PromptDecimalOrInteger(string prompt, NumberType type, decimal minValue, decimal maxValue, bool verbose) { decimal result; bool showMessage = false; do { string response = ""; response = GetResponse(prompt, type, minValue, maxValue, showMessage); try { result = (type == NumberType.Integer) ? Convert.ToInt32(response) : Convert.ToDecimal(response); if (IsInRange(result, minValue, maxValue)) { return(result); } showMessage = verbose; } catch (Exception e) when(e is OverflowException || e is FormatException || e is ArgumentNullException) { showMessage = verbose; continue; } } while (true); }
private static List <int> GetNumbers(NumberType numberType, List <int> addends) { int modResult = numberType == NumberType.Even ? 0 : 1; List <int> selectedNumbers = new List <int>(); //for (int i = 0; i < addends.Count; i++) //{ // if (addends[i] % 2 == modResult) // selectedNumbers.Add(addends[i]); //} //int count = 0; foreach (int addend in addends) { //if (count < 40) //{ // count++; // continue; //} if (Math.Abs(addend % 2) == modResult) { selectedNumbers.Add(addend); } } return(selectedNumbers); }
/// <summary> /// 比较:大于 /// </summary> /// <param name="numA"></param> /// <param name="numB"></param> /// <returns></returns> public static bool operator >(RationalNumber numA, RationalNumber numB) { NumberType a = numA.Numerator * numB.Denominator; NumberType b = numB.Numerator * numA.Denominator; return(a > b); }
/// <summary> /// Renders the base control. /// </summary> /// <param name="writer">The writer.</param> public override void RenderBaseControl(HtmlTextWriter writer) { string numberType = NumberType.ConvertToString(); if (numberType == "Integer") { this.Attributes["pattern"] = "[0-9]*"; } var minValue = MinimumValue.AsIntegerOrNull(); if (minValue.HasValue) { this.Attributes["min"] = minValue.ToString(); } var maxValue = MaximumValue.AsIntegerOrNull(); if (maxValue.HasValue) { this.Attributes["max"] = maxValue.ToString(); } base.RenderBaseControl(writer); }
public static FieldType ToFieldType(this NumberType numberType) { switch (numberType) { case NumberType.Float: return(FieldType.Float); case NumberType.HalfFloat: return(FieldType.HalfFloat); case NumberType.ScaledFloat: return(FieldType.ScaledFloat); case NumberType.Double: return(FieldType.Double); case NumberType.Integer: return(FieldType.Integer); case NumberType.Long: return(FieldType.Long); case NumberType.Short: return(FieldType.Short); case NumberType.Byte: return(FieldType.Byte); case NumberType.UnsignedLong: return(FieldType.UnsignedLong); default: throw new ArgumentOutOfRangeException(nameof(numberType), numberType, null); } }
public MorphoSyntacticFeatures(NumberType num, PersonType pers, TenseFormationType tma, TensePositivity posit, TensePassivity voice) { Number = num; Person = pers; TenseMoodAspect = tma; Positivity = posit; Voice = voice; }
public Value(BigRational realPart, BigRational imaginaryPart, NumberType type) { switch (type) { case NumberType.imaginary: InitComplexNum(realPart, imaginaryPart); break; } }
public Value(BigRational baseVal, BigRational exponent, NumberType type, Restrictions restrictions) { switch (type) { case NumberType.exponent: InitExp(baseVal, exponent, restrictions); break; } }
public Value(double realPart, double imaginaryPart, NumberType type) { switch (type) { case NumberType.imaginary: InitComplexNum(realPart, imaginaryPart); break; } }
public Value(int numerator, int denomenator, NumberType type) { switch (type) { case NumberType.fractional: InitFraction(numerator, denomenator); break; } }
public Value(double baseVal, double exponent, NumberType type, Restrictions restrictions) { switch (type) { case NumberType.exponent: InitExp(baseVal, exponent, restrictions); break; } }
/// <summary> /// /// </summary> public StepStruct() { NumbersList = new List<KeyValuePair<NumberType, string>>() { new KeyValuePair<NumberType, string>(NumberType.SystemVersion, "System.Version - .NET (CLR)"), new KeyValuePair<NumberType, string>(NumberType.NativeStruct, "Native struct") }; fnumber = NumbersList[0].Key; }
public static Number Abs(Number value, NumberType type) { switch (type) { case NumberType.Float: return FromFloat(Math.Abs(value.Float)); default: throw new InvalidOperationException(string.Format("Abs is not a valid operation for number type '{0}'.", type)); } }
public static void handleNumberkeyDown(TextType _texttype, ref KeyEventArgs e, NumberType _NumberType, NumberPower __NumberPower) { bool result = true; bool numericKeys = ( ((e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9) || (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9)) && e.Modifiers != Keys.Shift); bool ctrlA = e.KeyCode == Keys.A && e.Modifiers == Keys.Control; bool mark = (e.KeyCode == Keys.OemMinus && __NumberPower != NumberPower.positiveOnly) || (e.KeyCode == Keys.Oemplus && __NumberPower != NumberPower.NegativeOnly); bool comma = (_NumberType != NumberType.Integer && (e.KeyData == Keys.Decimal || e.KeyCode == Keys.Oemcomma || e.KeyCode == Keys.OemPeriod)); bool editKeys = ( (e.KeyCode == Keys.Z && e.Modifiers == Keys.Control) || (e.KeyCode == Keys.X && e.Modifiers == Keys.Control) || (e.KeyCode == Keys.C && e.Modifiers == Keys.Control) || (e.KeyCode == Keys.V && e.Modifiers == Keys.Control) || e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back); bool navigationKeys = ( e.KeyCode == Keys.Up || e.KeyCode == Keys.Right || e.KeyCode == Keys.Down || e.KeyCode == Keys.Left || e.KeyCode == Keys.Home || e.KeyCode == Keys.End); switch (_texttype) { case TextType.IsNumber: { if (!(numericKeys || editKeys || navigationKeys || mark || comma)) { if (ctrlA) // Do select all as OS/Framework does not always seem to implement this. // SelectAll(); result = false; } if (!result) // If not valid key then suppress and handle. { e.SuppressKeyPress = true; e.Handled = true; if (ctrlA) { } // Do Nothing! } break; } case TextType.IsdateTime: break; case TextType.IsMail: break; case TextType.IsString: break; case TextType.IsTel: break; } }
/// <summary> /// Creates a new instance of the NumericTextBox /// </summary> public HNumericTextBox() { TextAlign = HorizontalAlignment.Right; TextType = TextType.IsNumber; _NumberType =NumberType.Decimal; _NumberPower = NumberPower.positiveOrNegative; regex = ClsRegex.numericGetRegex(TextType.IsNumber, _NumberType, _NumberPower); _minValue = -10000000; _maxValue = 10000000; if (_required == true) BackColor = _requiredColor; }
public void NumberTypeNames() { var expected = new[] { "System.Int32", "System.UInt32", "System.Int64", "System.UInt64", "System.Byte", "System.SByte", "System.Int16", "System.UInt16" }; var actual = new NumberType().TypeNames; TestHelper.AreEqual(expected, actual); }
public FloatingNumber(ContentManager Content, NumberType type) { this.Content = Content; shouldRise = true; timer = new Timer(DamageTime); this.type = type; offsetY = 0; val = 0; centerX = 0; centerY = 0; }
public override EvalType Evaluate(EvalContext context, params ExprNode[] p) { //TODO: Check range. var inc = new NumberType("1", UnitType.Empty()); var mv = p[0].Evaluate(context); var tv = new NumberType("1", UnitType.Empty()); for (NumberType i = new NumberType("1", UnitType.Empty()); i.LessEql(mv); i += inc) { tv *= i; } return tv; }
public static Number Negate(Number value, NumberType type) { switch (type) { case NumberType.Int: return FromInt(-value.Int); case NumberType.Float: return FromFloat(-value.Float); default: throw new InvalidOperationException(string.Format("Negate is not a valid operation for number type '{0}'.", type)); } }
public override EvalType Evaluate(EvalContext context, params ExprNode[] p) { if (p.Length != 1) throw new Exception("Invalid number of parameters."); var en = p[0].Evaluate(context); if (en is NumberType) return en; var nl = en as NumberListType; NumberType mag = new NumberType(0, UnitType.Empty()); for (int i = 0; i < nl.Length; i++) mag += nl[i]; return mag; }
public override EvalType Evaluate(EvalContext context, params ExprNode[] p) { if (p.Length != 4) throw new Exception("Invalid number of parameters."); NumberType sum = new NumberType("0", UnitType.Empty()); NumberType inc = new NumberType("1", UnitType.Empty()); //EvalContext c = new EvalContext(context, ((VariableNode)p[1]).Variable) for (NumberType i = (p[2].Evaluate(context) as NumberType).Copy(); i.LessEql(p[3].Evaluate(context)); i += inc) { context.VariableList[((VariableNode)p[1]).Variable] = i; sum += p[0].Evaluate(context) as NumberType; } return sum; }
public static Number4 Negate(Number4 original, NumberType type) { switch (type) { case NumberType.Float: return NegateFloat(original); case NumberType.Int: return NegateInt(original); case NumberType.Double: return NegateDouble(original); default: throw new InvalidOperationException(string.Format("Negate is not a valid operation for number type '{0}'.", type)); } }
public Token(string lexeme, PersianPOSTag persianPOSTag, string lemma, NumberType numberType, int length, int startPos, ENUM_TENSE_PERSON person) { Lexeme = lexeme; POSTag = persianPOSTag; Lemma = lemma; Number = numberType; Length = length; Lemma = lemma; Lexeme = lexeme; Person = person; POSTag = persianPOSTag; StartPos = startPos; }
/// <summary> /// 数字を文字列に変換します。 /// </summary> public static string ConvertInt(NumberType type, int num) { string[] numberTable; var result = new StringBuilder(); switch (type) { case NumberType.Normal: numberTable = NormalNumberTable; break; case NumberType.Big: numberTable = BigNumberTable; break; case NumberType.Kanji: numberTable = KanjiNumberTable; break; case NumberType.Grade: numberTable = NormalNumberTable; if (num == 1) { return "初"; } break; default: return null; } if (num == 0) { return numberTable[0]; } // 負数ならマイナス記号をつけます。 var original = num; num = (num > 0 ? num : -num); while (num > 0) { result.Insert(0, numberTable[num % 10]); num /= 10; } if (original < 0) { result.Insert(0, numberTable[10]); } return result.ToString(); }
public override EvalType Evaluate(EvalContext context, params ExprNode[] p) { if (p.Length != 1) throw new Exception("Invalid number of parameters."); var en = p[0].Evaluate(context); if (en is NumberType) return new NumberType(Math.Abs((en as NumberType).value), (en as NumberType).Unit); var nl = en as NumberListType; NumberType mag = new NumberType(0, UnitType.Empty()); NumberType two = new NumberType(2, UnitType.Empty()); NumberType oneOverTwo = new NumberType(.5, UnitType.Empty()); for (int i = 0; i < nl.Length; i++) mag += nl[i] ^ two; return mag ^ oneOverTwo; }
public static Number4 ApplyOperandModifier(Number4 value, NumberType numberType, OperandModifier modifier) { switch (modifier) { case OperandModifier.None: return value; case OperandModifier.Neg: return Number4.Negate(value, numberType); case OperandModifier.Abs: return Number4.Abs(value, numberType); case OperandModifier.AbsNeg: return Number4.Negate(Number4.Abs(value, numberType), numberType); default: throw new ArgumentOutOfRangeException("modifier"); } }
public static Number4 Abs(Number4 original, NumberType type) { switch (type) { case NumberType.Float: case NumberType.Int: case NumberType.UInt: return new Number4( Number.Abs(original.Number0, type), Number.Abs(original.Number1, type), Number.Abs(original.Number2, type), Number.Abs(original.Number3, type)); case NumberType.Double: return new Number4( Math.Abs(original.Double0), Math.Abs(original.Double1)); default: throw new InvalidOperationException(string.Format("Abs is not a valid operation for number type '{0}'.", type)); } }
public static string numericGetRegex(TextType _TextType, NumberType _numbertype, NumberPower _NumberPower ) { string Regex = ""; if (_TextType == TextType.IsNumber) { ///جزء العلامة الاشارة switch (_NumberPower) { case NumberPower.positiveOrNegative: Regex +="("+PositivePt +"|"+ negativePt +")"; break; case NumberPower.NegativeOnly: Regex += negativePt ; break; case NumberPower.positiveOnly: Regex += PositivePt; break; } /// جزء العلامة العشرية switch (_numbertype ) { case NumberType.Integer: Regex += IntegerPt; break; case NumberType.Decimalonly: Regex += DecimalPt; break; case NumberType.Decimal : Regex +="("+IntegerPt+"|"+ IntegerPt + DecimalPt+")"; break; } Regex += "$"; } return Regex ; }
private void WriteValues(XmlTextWriter writer, NumberType numType, String[] elements, String[] values, NumberFormatInfo info){ switch(numType){ case NumberType.Int: { Int64 value; for(int i=0; i<numberTable.Length; i++){ value = numberTable[i]; writer.WriteStartElement("Table"); writer.WriteElementString("Number", value.ToString(info)); for(int j=0; j<elements.Length; j++){ writer.WriteElementString(elements[j], value.ToString(values[j], info)); } writer.WriteEndElement(); } break; } case NumberType.Decimal: { Decimal value; for(int i=0; i<decimalTable.Length; i++){ value = decimalTable[i]; writer.WriteStartElement("Table"); writer.WriteElementString("Number", value.ToString(info)); for(int j=0; j<elements.Length; j++){ writer.WriteElementString(elements[j], value.ToString(values[j], info)); } writer.WriteEndElement(); } break; } case NumberType.Double: { Double value; for(int i=0; i<doubleTable.Length; i++){ value = doubleTable[i]; writer.WriteStartElement("Table"); writer.WriteElementString("Number", value.ToString("R", info)); for(int j=0; j<elements.Length; j++){ writer.WriteElementString(elements[j], value.ToString(values[j], info)); } writer.WriteEndElement(); } break; } } writer.WriteEndElement(); writer.Flush(); writer.Close(); }
/// <summary>Fraction</summary> public void InitFraction(int numerator, int denominator) { this.numerator = new Value(numerator, Restrictions.dontSetToFraction); this.denominator = new Value(denominator, Restrictions.dontSetToFraction); this.deciValue = ((double)numerator / denominator); this.primaryNumType = NumberType.fractional; rational = new MathNet.Numerics.Rational(numerator, denominator); }
/// <summary>Exponent</summary> public void InitExp(double expBase, double expPower, Restrictions restrictionsToPass) { this.ExpBase = new Value(expBase, restrictionsToPass); this.ExpPower = new Value(expPower, restrictionsToPass); this.deciValue = (Math.Pow(expBase, expPower)); primaryNumType = NumberType.exponent; }
/// <summary>Decimal value</summary> public void InitDouble(double val, Restrictions restrictions) { this.deciValue = val; if (val == Math.Floor(val)) { //this is done to avoid the accumulation of miniscule errors: deciValue = Math.Floor(val); primaryNumType = NumberType.integer; if (restrictions != Restrictions.dontFactorMe && restrictions != Restrictions.dontFactorDontSetFraction) { factors = new Factors((int)deciValue); } natural = new MathNet.Numerics.Natural(); }else if (restrictions != Restrictions.dontSetToFraction && restrictions != Restrictions.dontFactorDontSetFraction) { asAFraction = decimalToFraction(deciValue); } this.primaryNumType = NumberType.deci; }