System.Convert.ToDecimal(float)

Here are the examples of the csharp api System.Convert.ToDecimal(float) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

24 Examples 7

19 Source : Half.cs
with MIT License
from 91Act

decimal IConvertible.ToDecimal(IFormatProvider provider)
        {
            return Convert.ToDecimal((float)this);
        }

19 Source : MainForm.cs
with GNU General Public License v3.0
from AgentRev

void InitFovChanger()
        {
            settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), (string)gameMode.GetValue("c_settingsDirName"));
            settingsFile = Path.Combine(settingsPath, (string)gameMode.GetValue("c_settingsFileName"));
            gameModeFile = Path.Combine(settingsPath, "gamemode.ini");

            pFoV = (dword_ptr)gameMode.GetValue("c_pFoV");
            fFoV = c_FoV;
            doBeep = c_doBeep;
            updateNotify = c_updateNotify;
            hotKeys = c_hotKeys;
            catchKeys = (Keys[])c_catchKeys.Clone();

            this.numFoV.Maximum = Convert.ToDecimal(c_FoV_upperLimit);
            this.numFoV.Minimum = Convert.ToDecimal(c_FoV_lowerLimit);

            if (File.Exists(settingsFile)) ReadSettings();

            lblVersion.Text = "v" + c_toolVer;
            lblVersion.Visible = true;

            IsGameInstalled();

            numFoV.Value = Convert.ToDecimal(fFoV);
            numFoV.Enabled = true;
            ToggleButton(!isRunning(false));
        }

19 Source : MainForm.cs
with GNU General Public License v3.0
from AgentRev

private void SetFoV(float val)
        {
            bool reset = val < 0 ? true : false;

            if (!reset)
            {
                if (val < c_FoV_lowerLimit)
                    fFoV = c_FoV_lowerLimit;
                else if (val > c_FoV_upperLimit)
                    fFoV = c_FoV_upperLimit;
                else
                    fFoV = val;
            }
            else
                SaveSettings();

            try
            {
                if (mem != null && isRunning(false) && writeAllowed)
                    mem.WriteFloat(pFoV, reset ? c_FoV : fFoV);
            }
            catch (Exception ex)
            {
                ErrMessage(ex);
                Application.Exit();
            }

            if (!reset)
            {
                numFoV.Value = Convert.ToDecimal(fFoV);
                SaveSettings();
            }
        }

19 Source : MainForm.cs
with GNU General Public License v3.0
from AgentRev

void InitFovChanger()
        {
            settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), (string)gameMode.GetValue("c_settingsDirName"));
            settingsFile = Path.Combine(settingsPath, (string)gameMode.GetValue("c_settingsFileName"));
            gameModeFile = Path.Combine(settingsPath, "gamemode.ini");

            pFoV = (int)gameMode.GetValue("c_pFoV");
            fFoV = c_FoV;
            doBeep = c_doBeep;
            updateChk = c_updateChk;
            hotKeys = c_hotKeys;
            catchKeys = (Keys[])c_catchKeys.Clone();

            this.numFoV.Maximum = Convert.ToDecimal(c_FoV_upperLimit);
            this.numFoV.Minimum = Convert.ToDecimal(c_FoV_lowerLimit);

            if (File.Exists(settingsFile)) ReadSettings();

            lblVersion.Text = "v" + c_toolVer;
            lblVersion.Visible = true;

            IsGameInstalled();

            numFoV.Value = Convert.ToDecimal(fFoV);
            numFoV.Enabled = true;
            ToggleButton(!isRunning(false));
        }

19 Source : CborReader.cs
with MIT License
from dahomey-technologies

[MethodImpl(MethodImplOptions.AggressiveInlining)]
        public decimal ReadDecimal()
        {
            SkipSemanticTag();
            CborReaderHeader header = GetHeader();

            switch (header.MajorType)
            {
                case CborMajorType.PositiveInteger:
                    return ReadInteger();

                case CborMajorType.NegativeInteger:
                    return -1L - (long)ReadInteger();

                case CborMajorType.Primitive:
                    {
                        switch (header.Primitive)
                        {
                            case CborPrimitive.HalfFloat:
                                return (decimal)(float)InternalReadHalf();

                            case CborPrimitive.SingleFloat:
                                return Convert.ToDecimal(InternalReadSingle());

                            case CborPrimitive.DoubleFloat:
                                return Convert.ToDecimal(InternalReadDouble());

                            case CborPrimitive.DecimalFloat:
                                return InternalReadDecimal();

                            default:
                                throw new CborException($"Invalid primitive {header.Primitive}");
                        }
                    }

                default:
                    throw new CborException($"Invalid major type {header.MajorType}");
            }
        }

19 Source : SingleRoughAdvancedConverter.cs
with MIT License
from DataObjects-NET

decimal IAdvancedConverter<float, decimal>.Convert(float value)
    {
      return Convert.ToDecimal(value);
    }

19 Source : BasicConvert.Overload.cs
with MIT License
from Dogwei

decimal IXConverter<float, decimal>.Convert(float value)
			=> Convert.ToDecimal(value);

19 Source : UnitConversion.cs
with MIT License
from dragonglasscom

private BigInteger CalculateNumberOfDecimalPlaces(float value, int maxNumberOfDecimals,
            int currentNumberOfDecimals = 0)
        {
            return CalculateNumberOfDecimalPlaces(System.Convert.ToDecimal(value), maxNumberOfDecimals,
                currentNumberOfDecimals);
        }

19 Source : UnitConversion.cs
with MIT License
from dragonglasscom

public BigInteger ToWei(float value, EthUnit fromUnit = EthUnit.Ether)
        {
            return ToWei(System.Convert.ToDecimal(value), fromUnit);
        }

19 Source : Half.cs
with MIT License
from emotitron

decimal IConvertible.ToDecimal(IFormatProvider provider)
		{
			return Convert.ToDecimal(this);
		}

19 Source : GeneralRecordWrapper.cs
with GNU Lesser General Public License v3.0
from faib920

public virtual decimal GetDecimal(IDataRecord reader, int i)
        {
            if (reader.IsDBNull(i))
            {
                return 0;
            }

            var type = reader.GetFieldType(i);
            if (type == typeof(decimal))
            {
                return reader.GetDecimal(i);
            }
            else if (type == typeof(byte))
            {
                return reader.GetByte(i);
            }
            else if (type == typeof(short))
            {
                return reader.GetInt16(i);
            }
            else if (type == typeof(int))
            {
                return reader.GetInt32(i);
            }
            else if (type == typeof(long))
            {
                return reader.GetInt64(i);
            }
            else if (type == typeof(float))
            {
                return Convert.ToDecimal(reader.GetFloat(i));
            }
            else if (type == typeof(double))
            {
                return Convert.ToDecimal(reader.GetDouble(i));
            }

            return Convert.ToDecimal(GetValue(reader, i));
        }

19 Source : VariableAggregator.cs
with MIT License
from influxdata

private Expression CreateExpression(NamedVariable variable)
        {
            // Handle string here to avoid conflict with IEnumerable
            if (variable.IsTag || variable.Value is string)
            {
                return CreateStringLiteral(variable);
            }

            switch (variable.Value)
            {
                case int i:
                    return new IntegerLiteral("IntegerLiteral", Convert.ToString(i));
                case long l:
                    return new IntegerLiteral("IntegerLiteral", Convert.ToString(l));
                case bool b:
                    return new BooleanLiteral("BooleanLiteral", b);
                case float f:
                    return new FloatLiteral("FloatLiteral", Convert.ToDecimal(f));
                case DateTime d:
                    return new DateTimeLiteral("DateTimeLiteral", d);
                case DateTimeOffset o:
                    return new DateTimeLiteral("DateTimeLiteral", o.UtcDateTime);
                case IEnumerable e:
                {
                    var expressions =
                        e.Cast<object>()
                         .Select(o => new NamedVariable { Value = o, IsTag = variable.IsTag })
                         .Select(CreateExpression)
                         .ToList();
                    return new ArrayExpression("ArrayExpression", expressions);
                }
                default:
                    return CreateStringLiteral(variable);
            }
        }

19 Source : SingleExtensions.cs
with GNU General Public License v3.0
from ME3Tweaks

public static decimal ToDecimal(this float value)
		{
			return Convert.ToDecimal(value);
		}

19 Source : General.cs
with MIT License
from ooojustin

public static void RefreshAimSettings(Dynago.Forms.Main main) {
        main.RefreshingAimSettings = true;
        WeaponSettings settings = Selected(main.cmb_aimbot_type);
        main.cb_aimbot_onkey.Checked = settings.aimbot_on_key;
        main.txt_aimbot_key.Text = settings.aimbot_key_txt;
        main.cmb_aimbot_bone.SelectedIndex = settings.aimbot_bone_index;
        main.nud_aimbot_fov.Value = Convert.ToDecimal(settings.aimbot_fov);
        main.nud_aimbot_smooth.Value = Convert.ToDecimal(settings.aimbot_smooth);
        main.cb_aimbot_rcs.Checked = settings.aimbot_control_recoil;
        main.cb_aimbot_target_teammates.Checked = settings.aimbot_shoot_teammates;
        main.cb_aimbot_target_enemies.Checked = settings.aimbot_shoot_enemies; 
        main.RefreshingAimSettings = false;
        main.txtDummy.Focus();
    }

19 Source : General.cs
with MIT License
from ooojustin

public static void RefreshTriggerSettings(Dynago.Forms.Main main) {
        main.RefreshingTriggerSettings = true;
        WeaponSettings settings = Selected(main.cmb_triggerbot_type);
        main.cb_trigger_onkey.Checked = settings.trigger_on_key;
        main.txt_trigger_key.Text = settings.trigger_key_txt;
        main.nud_trigger_delay.Value = Convert.ToDecimal(settings.trigger_delay);
        main.nud_trigger_overshoot.Value = Convert.ToDecimal(settings.trigger_overshoot);
        main.cb_trigger_shoot_teammates.Checked = settings.trigger_shoot_teammates;
        main.cb_trigger_shoot_enemies.Checked = settings.trigger_shoot_enemies;
        main.cb_trigger_magnetic.Checked = settings.trigger_magnetic;
        main.cmb_trigger_magnet_bone.SelectedIndex = settings.trigger_magnet_bone_index;
        main.nud_trigger_magnet_fov.Value = Convert.ToDecimal(settings.trigger_magnet_fov);
        main.nud_trigger_magnet_smooth.Value = Convert.ToDecimal(settings.trigger_magnet_smooth);
        main.RefreshingTriggerSettings = false;
        main.txtDummy.Focus();
    }

19 Source : Half.cs
with MIT License
from overtools

decimal IConvertible.ToDecimal(IFormatProvider provider) {
            return Convert.ToDecimal((float)this);
        }

19 Source : BigNumber.cs
with MIT License
from scellecs

public static BigNumber Parse(string value) {
            var re = new Regex(REGEXP_PATTERN);
            var result = re.Match(value);

            if (result.Groups.Count > 1)
            {
                var dcml = Convert.ToDecimal(float.Parse(result.Groups[1].Value, CultureInfo.InvariantCulture));
                var chr = result.Groups[2].Value;

                return new BigNumber(dcml, chr);
            }
             
            return new BigNumber(BigInteger.Parse(value));
        }

19 Source : FloatConvertor.cs
with GNU General Public License v3.0
from SeeSharpOpenSource

protected override void InitializeConvertFuncs()
        {
            ConvertFuncs.Add(typeof(decimal).Name, sourceValue => System.Convert.ToDecimal((float)sourceValue));
            ConvertFuncs.Add(typeof(double).Name, sourceValue => System.Convert.ToDouble((float)sourceValue));
//            ConvertFuncs.Add(typeof(float).Name, sourceValue => System.Convert.ToSingle((float)sourceValue));
            ConvertFuncs.Add(typeof(long).Name, sourceValue => System.Convert.ToInt64((float)sourceValue));
            ConvertFuncs.Add(typeof(ulong).Name, sourceValue => System.Convert.ToUInt64((float)sourceValue));
            ConvertFuncs.Add(typeof(int).Name, sourceValue => System.Convert.ToInt32((float)sourceValue));
            ConvertFuncs.Add(typeof(uint).Name, sourceValue => System.Convert.ToUInt32((float)sourceValue));
            ConvertFuncs.Add(typeof(short).Name, sourceValue => System.Convert.ToInt16((float)sourceValue));
            ConvertFuncs.Add(typeof(ushort).Name, sourceValue => System.Convert.ToUInt16((float)sourceValue));
            ConvertFuncs.Add(typeof(char).Name, sourceValue => System.Convert.ToChar((float)sourceValue));
            ConvertFuncs.Add(typeof(byte).Name, sourceValue => System.Convert.ToByte((float)sourceValue));
            ConvertFuncs.Add(typeof(bool).Name, sourceValue => (float)sourceValue > 0);
            ConvertFuncs.Add(typeof(string).Name, sourceValue => ((float)sourceValue).ToString(_format));
        }

19 Source : Calculator.cs
with MIT License
from SouthBegonia

public void CalculateFirst()
    {
        // 从各项text取得数值
        Num_Dw = Convert.ToDecimal(Dw.text);
        Num_D = Convert.ToDecimal(DD.text);
        Num_d = Convert.ToDecimal(dd.text);
        Num_Z = Convert.ToDecimal(Z.text);
        Num_fi = Convert.ToDecimal(0.515f);
        Num_fe = Convert.ToDecimal(0.525f);
        Num_fr = Convert.ToDecimal(fr.text);

        // 曲率和、曲率差的计算
        内环.d = ((Num_D + Num_d) / (decimal)2.0 - Num_Dw);
        内环.r = decimal.Round((Num_fi * Num_Dw), 2, MidpointRounding.AwayFromZero);
        内环.曲率和 = (4 / Num_Dw) + (2 / 内环.d) - (1 / 内环.r);
        内环.曲率差 = ((1 / 内环.r) + (2 / 内环.d)) / 内环.曲率和;

        外环.d = ((Num_D + Num_d) / 2 + Num_Dw);
        外环.r = decimal.Round((Num_fe * Num_Dw), 2, MidpointRounding.AwayFromZero);
        外环.曲率和 = (4 / Num_Dw) - (2 / 外环.d) - (1 / 外环.r);
        外环.曲率差 = ((1 / 外环.r) - (2 / 外环.d)) / 外环.曲率和;

        // 最大接触载荷Qmax的计算
        if (fr.text != null)
            Num_Qmax = (5 * Num_fr) / Num_Z;


        // 刷新UI
        //曲率和、曲率差
        内环.曲率和 = decimal.Round(内环.曲率和, 5, MidpointRounding.AwayFromZero);
        内环.曲率差 = decimal.Round(内环.曲率差, 5, MidpointRounding.AwayFromZero);
        ans_内环_曲率和.text = 内环.曲率和.ToString("F5");
        ans_内环_曲率差.text = 内环.曲率差.ToString("F5");
        外环.曲率和 = decimal.Round(外环.曲率和, 5, MidpointRounding.AwayFromZero);
        外环.曲率差 = decimal.Round(外环.曲率差, 5, MidpointRounding.AwayFromZero);
        ans_外环_曲率和.text = 外环.曲率和.ToString("F5");
        ans_外环_曲率差.text = 外环.曲率差.ToString("F5");

        //Qmax
        Num_Qmax = decimal.Round(Num_Qmax, 5, MidpointRounding.AwayFromZero);
        ans_Qmax.text = Num_Qmax.ToString() + " N";
    }

19 Source : Single.cs
with MIT License
from spaceflint7

System.Decimal System.IConvertible.ToDecimal(System.IFormatProvider provider)
            => System.Convert.ToDecimal(Get());

19 Source : Single.cs
with MIT License
from Team-RTCLI

decimal IConvertible.ToDecimal(IFormatProvider? provider)
        {
            return Convert.ToDecimal(m_value);
        }

19 Source : ObfuscatedFloat.cs
with MIT License
from vovgou

decimal IConvertible.ToDecimal(IFormatProvider provider)
        {
            return Convert.ToDecimal(this.Value);
        }

19 Source : FluentValidationSchemaProcessorTest.cs
with MIT License
from zymlabs

[Fact]
        public void ProcessIncludesDefaultRuleValueInRangeDouble()
        {
            // Arrange
            var jsonSchemaGeneratorSettings = CreateJsonSchemaGeneratorSettings();

            // Act
            var schema = JsonSchema.FromType<MockValidationTarget>(jsonSchemaGeneratorSettings);

            // replacedert
            replacedert.Equal(Convert.ToDecimal(2.2), schema.Properties["ValueInRangeDouble"].ExclusiveMinimum);
            replacedert.Equal(Convert.ToDecimal(7.5f), schema.Properties["ValueInRangeDouble"].ExclusiveMaximum);
        }

19 Source : FluentValidationSchemaProcessorTest.cs
with MIT License
from zymlabs

[Fact]
        public void ProcessIncludesDefaultRuleValueInRangeFloat()
        {
            // Arrange
            var jsonSchemaGeneratorSettings = CreateJsonSchemaGeneratorSettings();

            // Act
            var schema = JsonSchema.FromType<MockValidationTarget>(jsonSchemaGeneratorSettings);

            // replacedert
            replacedert.Equal(Convert.ToDecimal(1.1f), schema.Properties["ValueInRangeFloat"].Minimum);
            replacedert.Equal(Convert.ToDecimal(5.3f), schema.Properties["ValueInRangeFloat"].Maximum);
        }