private static SpriteRenderer GetNumIcon(int num, NumType type) { if (type == NumType.Yellow_light) { return(ResourceManager.GetIconSprite("new_z_vip_" + num)); } if (type == NumType.Yellow) { return(ResourceManager.GetIconSprite("font_vip_" + num)); } if (type == NumType.Yellow_big) { return(ResourceManager.GetIconSprite("ts_" + num)); } if (type == NumType.jn) { return(ResourceManager.GetIconSprite("jn_" + num)); } if (type == NumType.EquipStarUp) { return(ResourceManager.GetIconSprite("sx" + num)); } if (type == NumType.Fight_time) { return(ResourceManager.GetIconSprite("fight_time_" + num)); } return(ResourceManager.GetIconSprite("font_vip_" + num)); }
public DisplayHint(string str) { _str = str; if (str.StartsWith("d")) { _type = NumType.dec; if (str.StartsWith("d-")) { _decimalPoints = Convert.ToInt32(str.Substring(2)); } } else if (str.StartsWith("o")) { _type = NumType.oct; } else if (str.StartsWith("h")) { _type = NumType.hex; } else if (str.StartsWith("b")) { _type = NumType.bin; } else { _type = NumType.str; foreach (char c in str) { } } }
public DisplayHint(string str) { _str = str; if (str.StartsWith("d")) { _type = NumType.Dec; if (str.StartsWith("d-")) { _decimalPoints = Convert.ToInt32(str.Substring(2)); } } else if (str.StartsWith("o")) { _type = NumType.Oct; } else if (str.StartsWith("h")) { _type = NumType.Hex; } else if (str.StartsWith("b")) { _type = NumType.Bin; } else { _type = NumType.Str; foreach (char c in str) { // TODO: } } }
public Value(BuffValueType _buffValueType, bool _enable, NumType _numType, NumOperator _numOperator, float _value) { this.buffValueType = _buffValueType; this.enable = _enable; this.numType = _numType; this.numOperator = _numOperator; this.value = _value; }
public static NumType operator *(NumType num1, float beilv) { NumType ret = num1; ret.others.Sort(); return(ret); }
private void SetCounts(List <double> counts, NumType type) { switch (type) { case NumType.Orders: Counts = counts.ConvertAll(c => c.ToString("0.")); break; case NumType.Money: Counts = counts.ConvertAll(c => c.ToString("$0.##")); break; } }
//执行了构造函数之后,doubleValue可能是不存在的,但stringValue一定存在 /// <summary> /// 构造函数 /// </summary> public CalNum(string stringValue) { this.stringValue = stringValue; if (stringValue.IndexOf(',') == -1)//防止如9,9转换成99,逗号已作为参数分隔符和算式分隔符使用 { double d; if (double.TryParse(stringValue.Replace(" ", ""), out d)) { this.doubleValue = d; } } this.numType = NumType.stringValue; }
public static SpriteRenderer GetNumIcon100(int num, NumType type) { SpriteRenderer result; if (num < 100) { result = ResourceManagerBase.GetNullSprite(); } else { result = GameDataUtils.GetNumIcon(num / 100, type); } return(result); }
/// <summary> /// 复制一个数值对象 /// </summary> /// <returns></returns> public object Clone() { NumType ret = new NumType(value, unit); if (others != null && others.Count > 0) { ret.others = new List <NumType>(); foreach (var item in others) { others.Add(item.Clone() as NumType); } } return(ret); }
private double GetCountFromQuery(IQueryable <Order> query, NumType type) { switch (type) { case NumType.Money: return(query.Sum(o => o.TotalPrice)); case NumType.Orders: return(query.Count()); default: return(0); } }
public static SpriteRenderer GetNumIcon1(int level, NumType type) { SpriteRenderer numIcon; if (level >= 100) { int num = level % 100 % 10; numIcon = GameDataUtils.GetNumIcon(num, type); } else { numIcon = GameDataUtils.GetNumIcon(level % 10, type); } return(numIcon); }
private ChartViewModel GetChartVMByDay(NumType type) { List <double> counts = new List <double>(); DateTime now = DateTime.Now.Date; for (int i = counColumn - 1; i >= 0; i--) { DateTime date = now.AddDays(-i); IQueryable <Order> query = db.Orders.Where(o => o.ClosedDate.Date.Equals(date)); double count = GetCountFromQuery(query, type); counts.Add(count); } return(new ChartViewModel(counts, type, Period.Day)); }
private void TestFormat(string valueStr, string formatString, string expectedResult, Case formatCase = Case.Both) { double value = Double.Parse(valueStr); // !!! does not return a negative number when parsed if string value does not contain a decimal point bool isNegative = false; NumType numType = NumType.All; if (value < 0) //if (valueStr.TrimStart()[0] == '-') { isNegative = true; } switch (formatString.ToUpper()[0]) { case 'D': case 'X': numType = NumType.IntOnly; break; default: if (value - (int)value != 0) // number with a fractional part { numType = NumType.FloatDoubleOnly; } break; } switch (formatCase) { case Case.Upper: TestFormatInner(valueStr, formatString.ToUpper(), expectedResult.ToUpper(), numType, isNegative); break; case Case.Lower: TestFormatInner(valueStr, formatString.ToLower(), expectedResult.ToLower(), numType, isNegative); break; case Case.Both: TestFormatInner(valueStr, formatString.ToUpper(), expectedResult.ToUpper(), numType, isNegative); TestFormatInner(valueStr, formatString.ToLower(), expectedResult.ToLower(), numType, isNegative); break; default: Assert.True(false, "Invalid format case used"); break; } }
public int Compare(NumType <NUMTYPE, NUM, A> mx, NumType <NUMTYPE, NUM, A> my) { if (ReferenceEquals(mx, my)) { return(0); } if (ReferenceEquals(mx, null)) { return(-1); } if (ReferenceEquals(my, null)) { return(1); } return(default(NUM).Compare((A)mx, (A)my)); }
public bool Equals(NumType <NUMTYPE, NUM, A> x, NumType <NUMTYPE, NUM, A> y) { if (ReferenceEquals(x, y)) { return(true); } if (ReferenceEquals(x, null)) { return(false); } if (ReferenceEquals(y, null)) { return(false); } return(default(NUM).Equals((A)x, (A)y)); }
private ChartViewModel GetChartVMByMonth(NumType type) { List <double> counts = new List <double>(); DateTime now = DateTime.Now.Date; for (int i = 6; i >= 0; i--) { DateTime date = now.AddMonths(-i); IQueryable <Order> query = db.Orders.Where(o => o.ClosedDate.Year.Equals(date.Year) && o.ClosedDate.Month.Equals(date.Month)); double count = GetCountFromQuery(query, type); counts.Add(count); } return(new ChartViewModel(counts, type, Period.Month)); }
public static SpriteRenderer GetNumIcon10(int level, NumType type) { SpriteRenderer result; if (level >= 100) { int num = level % 100 / 10; result = GameDataUtils.GetNumIcon(num, type); } else if (level >= 10 && level < 100) { result = GameDataUtils.GetNumIcon(level / 10, type); } else { result = ResourceManagerBase.GetNullSprite(); } return(result); }
/// <summary> /// /// </summary> /// <param name="type">The type of the number. Can be float, double, integer, long. Required.</param> /// <param name="indexName">The name of the field that will be stored in the index. Defaults to the property/field name.</param> /// <param name="index">Set to no if the value should not be indexed. In this case, store should be set to yes, since if its not indexed and not stored, there is nothing to do with it.</param> /// <param name="store">Set to yes the store actual field in the index, no to not store it. Defaults to no (note, the JSON document itself is stored, and it can be retrieved from it).</param> /// <param name="precisionStep">The precision step (number of terms generated for each number value). Defaults to 4.</param> /// <param name="boost">The boost value. Defaults to 1.0.</param> /// <param name="nullValue">When there is a (JSON) null value for the field, use the null_value as the field value. Defaults to not adding the field at all.</param> /// <param name="includeInAll">Should the field be included in the _all field (if enabled). Defaults to true or to the parent object type setting.</param> public NumberFieldSetting AddNumField(string name, NumType type = NumType.Integer, string indexName = null, IndexType index = IndexType.analyzed, Store store = Store.no, int precisionStep = 4, double boost = 1.0, string nullValue = null, bool includeInAll = true) { Contract.Assert(_fieldSettings != null); var field = new NumberFieldSetting(); field.Name = name; var numType = "integer"; switch (type) { case NumType.Long: numType = "long"; break; case NumType.Double: numType = "double"; break; case NumType.Float: numType = "float"; break; } field.Type = numType; field.IndexName = indexName; field.Store = store; field.PrecisionStep = precisionStep; field.Boost = boost; field.NullValue = nullValue; field.IncludeInAll = includeInAll; _fieldSettings[name] = field; return(field); }
public void Draw(int number, NumType type, int palette, string format, Vector2 location, Vector2 scale, float fade = 1f, Font.ColorID color = Font.ColorID.White) { if (type == NumType.sysfnt) { Memory.font.RenderBasicText(number.ToString(), location, scale, Font.Type.sysfnt, Fade: fade, color: color); return; } else if (type == NumType.sysFntBig) { Memory.font.RenderBasicText(number.ToString(), location, scale, Font.Type.sysFntBig, Fade: fade, color: color); return; } else if (type == NumType.menuFont) { Memory.font.RenderBasicText(number.ToString(), location, scale, Font.Type.menuFont, Fade: fade, color: color); return; } ID[] numberstarts = { ID.Num_8x8_0_0, ID.Num_8x8_1_0, ID.Num_8x8_2_0, ID.Num_8x16_0_0, ID.Num_8x16_1_0, ID.Num_16x16_0_0 }; List <ID>[] nums = new List <ID> [numberstarts.Length]; int j = 0; foreach (ID id in numberstarts) { nums[j] = new List <ID>(10); for (byte i = 0; i < 10; i++) { nums[j].Add(id + i); } j++; } IEnumerable <int> intList = number.ToString(format).Select(digit => int.Parse(digit.ToString())); Rectangle dst = new Rectangle { Location = location.ToPoint() }; foreach (int i in intList) { Draw(nums[(int)type][i], palette, dst, scale, fade); dst.Offset(Entries[nums[(int)type][i]].GetRectangle.Width * scale.X, 0); } }
public String getNumFieldAndOption(String fieldName, NumType type = NumType.INT, Boolean unsigned = false, Boolean zeroFill = false, Double Default = 0, Boolean autoIncrement = false, Boolean primaryKey = false, int size = 1) { String field = fieldName; if (type == NumType.INTEGER) { field += " " + type.ToString(); } else { field += " " + type.ToString() + "[" + size.ToString() + "]"; } if (unsigned) { field += " UNSIGNED"; } if (zeroFill) { field += " ZEROFILL"; } else { field += " NOT NULL";//숫자형은 무조건 not null이다. if (type == NumType.REAL || type == NumType.FLOAT || type == NumType.DOUBLE) { field += " DEFAULT " + Default; } else { field += " DEFAULT " + ((int)Default).ToString(); } } if (primaryKey) { field += " PRIMARY KEY"; } return(field); }
static void Main(string[] args) { // 1. The first step is to prompt the user for a number type // 2. Create the appropriate Number based on the number type (e.g. Binary, Octal, or Hexadecimal); set the number into Number num1. // 3. Prompt for an op char; create an operator instance based on the input --> Operations operation based on the number type with the op char. // 4. Create the appropriate Number based on the number type (e.g. Binary, Octal, or Hexadecimal); set the number into Number num2. // 5. Invoke the appropriate operation. Screen screen = new Screen(); Binary binary; NumType numType; if (!Enum.TryParse <NumType>("Oct", out numType)) { Console.WriteLine("Invalid number type"); } Bits a = screen.input(); screen.output(a); Bits b = screen.input(); screen.output(b); Bits c; Console.WriteLine($"Enter a Number Type:"); NumType d = Console.ReadLine(); Operations op1 = new Binary(a); op1.op = Convert.ToChar(Console.ReadLine()); if (op1.op.Equals('+')) { c = op1.addtion(b); Console.WriteLine(c); } Console.WriteLine(a.type()); }
private ChartViewModel GetChartVMByWeek(NumType type) { DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo; Calendar cal = dfi.Calendar; List <double> counts = new List <double>(); DateTime now = DateTime.Now.Date; for (int i = counColumn - 1; i >= 0; i--) { DateTime date = now.AddDays(-7 * i); int week = cal.GetWeekOfYear(date, dfi.CalendarWeekRule, dfi.FirstDayOfWeek) - 1; IQueryable <Order> query = db.Orders .Where(o => o.ClosedDate.Year.Equals(date.Year) && ((o.ClosedDate.DayOfYear - 1) / 7).Equals(week)); double count = GetCountFromQuery(query, type); counts.Add(count); } return(new ChartViewModel(counts, type, Period.Week)); }
//---------------------------------------------------- public CResultAErreur Serialize(C2iSerializer serializer) { int nVersion = GetNumVersion(); CResultAErreur result = serializer.TraiteVersion(ref nVersion); if (!result) { return(result); } serializer.TraiteString(ref _str); int nTmp = (int)_type; serializer.TraiteInt(ref nTmp); _type = (NumType)nTmp; if (!result) { return(result); } serializer.TraiteInt(ref _decimalPoints); return(result); }
public IActionResult GetChartViewModel(NumType type, Period period) { ChartViewModel cvm; switch (period) { case Period.Day: cvm = GetChartVMByDay(type); break; case Period.Week: cvm = GetChartVMByWeek(type); break; case Period.Month: cvm = GetChartVMByMonth(type); break; default: cvm = new ChartViewModel(); break; } return(PartialView(cvm)); }
public IWidget Visit(NumType type) { return(new UpDownWidget()); }
public int GetHashCode(NumType <NUMTYPE, NUM, A> x) => default(HashableNumType <NUMTYPE, NUM, A>).GetHashCode(x);
private void TestFormatInner(string valueStr, string formatString, string expectedResult, NumType numType, bool isNegative) { SampleDisplay.RowData rowData = sampleDisplay.AddRow(valueStr, formatString); double value = Double.Parse(valueStr); if (value <= SByte.MaxValue && value >= SByte.MinValue && (numType == NumType.IntOnly || numType == NumType.All) ) { CheckValue(sbyte.Parse(valueStr), valueStr, formatString, expectedResult, SampleDisplay.ColumnType.SByte, rowData); Assert.True(sbyte.TryParse(valueStr, out sbyte result), $"TryParse failed for sbyte {valueStr}"); CheckValue(result, valueStr, formatString, expectedResult, SampleDisplay.ColumnType.SByte, rowData); } if (value <= Int16.MaxValue && value >= Int16.MinValue && (numType == NumType.IntOnly || numType == NumType.All) ) { CheckValue(short.Parse(valueStr), valueStr, formatString, expectedResult, SampleDisplay.ColumnType.Int16, rowData); Assert.True(short.TryParse(valueStr, out short result), $"TryParse failed for short {valueStr}"); CheckValue(result, valueStr, formatString, expectedResult, SampleDisplay.ColumnType.Int16, rowData); } if (value <= Int32.MaxValue && value >= Int32.MinValue && (numType == NumType.IntOnly || numType == NumType.All) ) { CheckValue(int.Parse(valueStr), valueStr, formatString, expectedResult, SampleDisplay.ColumnType.Int32, rowData); Assert.True(int.TryParse(valueStr, out int result), $"TryParse failed for int {valueStr}"); CheckValue(result, valueStr, formatString, expectedResult, SampleDisplay.ColumnType.Int32, rowData); } if (value <= Int64.MaxValue && value >= Int64.MinValue && (numType == NumType.IntOnly || numType == NumType.All) ) { CheckValue(long.Parse(valueStr), valueStr, formatString, expectedResult, SampleDisplay.ColumnType.Int64, rowData); Assert.True(long.TryParse(valueStr, out long result), $"TryParse failed for long {valueStr}"); CheckValue(result, valueStr, formatString, expectedResult, SampleDisplay.ColumnType.Int64, rowData); } if (value <= Byte.MaxValue && value >= Byte.MinValue && (numType == NumType.IntOnly || numType == NumType.All) && !isNegative) { CheckValue(byte.Parse(valueStr), valueStr, formatString, expectedResult, SampleDisplay.ColumnType.Byte, rowData); Assert.True(byte.TryParse(valueStr, out byte result), $"TryParse failed for byte {valueStr}"); CheckValue(result, valueStr, formatString, expectedResult, SampleDisplay.ColumnType.Byte, rowData); } if (value <= UInt16.MaxValue && value >= UInt16.MinValue && (numType == NumType.IntOnly || numType == NumType.All) && !isNegative) { CheckValue(ushort.Parse(valueStr), valueStr, formatString, expectedResult, SampleDisplay.ColumnType.UInt16, rowData); Assert.True(ushort.TryParse(valueStr, out ushort result), $"TryParse failed for ushort {valueStr}"); CheckValue(result, valueStr, formatString, expectedResult, SampleDisplay.ColumnType.UInt16, rowData); } if (value <= UInt32.MaxValue && value >= UInt32.MinValue && (numType == NumType.IntOnly || numType == NumType.All) && !isNegative) { CheckValue(uint.Parse(valueStr), valueStr, formatString, expectedResult, SampleDisplay.ColumnType.UInt32, rowData); Assert.True(uint.TryParse(valueStr, out uint result), $"TryParse failed for uint {valueStr}"); CheckValue(result, valueStr, formatString, expectedResult, SampleDisplay.ColumnType.UInt32, rowData); } if (value <= UInt64.MaxValue && value >= UInt64.MinValue && (numType == NumType.IntOnly || numType == NumType.All) && !isNegative) { CheckValue(ulong.Parse(valueStr), valueStr, formatString, expectedResult, SampleDisplay.ColumnType.UInt64, rowData); Assert.True(ulong.TryParse(valueStr, out ulong result), $"TryParse failed for ulong {valueStr}"); CheckValue(result, valueStr, formatString, expectedResult, SampleDisplay.ColumnType.UInt64, rowData); } if (value <= Single.MaxValue && value >= Single.MinValue && (numType == NumType.FloatDoubleOnly || numType == NumType.All) ) { CheckValue(float.Parse(valueStr), valueStr, formatString, expectedResult, SampleDisplay.ColumnType.Single, rowData); Assert.True(float.TryParse(valueStr, out float result), $"TryParse failed for float {valueStr}"); CheckValue(result, valueStr, formatString, expectedResult, SampleDisplay.ColumnType.Single, rowData); } if (value <= Double.MaxValue && value >= Double.MinValue && (numType == NumType.FloatDoubleOnly || numType == NumType.All) ) { CheckValue(double.Parse(valueStr), valueStr, formatString, expectedResult, SampleDisplay.ColumnType.Double, rowData); Assert.True(double.TryParse(valueStr, out double result), $"TryParse failed for double {valueStr}"); CheckValue(result, valueStr, formatString, expectedResult, SampleDisplay.ColumnType.Double, rowData); } }
public Task <int> CompareAsync(NumType <NUMTYPE, NUM, A> x, NumType <NUMTYPE, NUM, A> y) => Compare(x, y).AsTask();
public Task <int> GetHashCodeAsync(NumType <NUMTYPE, NUM, A> x) => GetHashCode(x).AsTask();
public Task <bool> EqualsAsync(NumType <NUMTYPE, NUM, A> x, NumType <NUMTYPE, NUM, A> y) => Equals(x, y).AsTask();
public int GetHashCode(NumType <NUMTYPE, NUM, A> x) => x.IsNull() ? 0 : x.GetHashCode();
/// <summary> /// 构造函数 /// </summary> public CalNum(double doubleValue, string stringValue) { this.doubleValue = doubleValue; this.stringValue = stringValue; this.numType = NumType.both; }
/// <summary> /// /// </summary> /// <param name="type">The type of the number. Can be float, double, integer, long. Required.</param> /// <param name="indexName">The name of the field that will be stored in the index. Defaults to the property/field name.</param> /// <param name="index">Set to no if the value should not be indexed. In this case, store should be set to yes, since if its not indexed and not stored, there is nothing to do with it.</param> /// <param name="store">Set to yes the store actual field in the index, no to not store it. Defaults to no (note, the JSON document itself is stored, and it can be retrieved from it).</param> /// <param name="precisionStep">The precision step (number of terms generated for each number value). Defaults to 4.</param> /// <param name="boost">The boost value. Defaults to 1.0.</param> /// <param name="nullValue">When there is a (JSON) null value for the field, use the null_value as the field value. Defaults to not adding the field at all.</param> /// <param name="includeInAll">Should the field be included in the _all field (if enabled). Defaults to true or to the parent object type setting.</param> public NumberFieldSetting AddNumField(string name, NumType type = NumType.Integer, string indexName = null, IndexType index = IndexType.analyzed, Store store = Store.no, int precisionStep = 4, double boost = 1.0, string nullValue = null, bool includeInAll = true) { Contract.Assert(_fieldSettings != null); var field = new NumberFieldSetting(); field.Name = name; var numType = "integer"; switch (type) { case NumType.Long: numType = "long"; break; case NumType.Double: numType = "double"; break; case NumType.Float: numType = "float"; break; } field.Type = numType; field.IndexName = indexName; field.Store = store; field.PrecisionStep = precisionStep; field.Boost = boost; field.NullValue = nullValue; field.IncludeInAll = includeInAll; _fieldSettings[name] = field; return field; }
public bool Equals(NumType <NUMTYPE, NUM, A> x, NumType <NUMTYPE, NUM, A> y) => default(EqNumType <NUMTYPE, NUM, A>).Equals(x, y);
/// <summary> /// 构造函数 /// </summary> public CalNum(double doubleValue) { this.doubleValue = doubleValue; this.stringValue = doubleValue.ToString(); this.numType = NumType.doubleValue; }