An explicit cast to double
like this isn’t necessary:
double trans = (double) trackBar1.Value / 5000.0;
Identifying the constant as 5000.0
(or as 5000d
) is sufficient:
double trans = trackBar1.Value / 5000.0;
double trans = trackBar1.Value / 5000d;
More Related Contents:
- How to convert Decimal to Double in C#?
- When should I use double instead of decimal?
- How To Represent 0.1 In Floating Point Arithmetic And Decimal
- How to convert numbers between hexadecimal and decimal
- decimal vs double! – Which one should I use and when? [duplicate]
- Formatting a float to 2 decimal places
- Converting string to double in C#
- C++ decimal data types
- Conversion of a decimal to double number in C# results in a difference
- Performing Math operations on decimal datatype in C#?
- Converting String To Float in C#
- Why c# decimals can’t be initialized without the M suffix?
- Double vs Decimal Rounding in C#
- Why can’t I unbox an int as a decimal?
- C# Double – ToString() formatting with two decimal places but no rounding
- Best way to display decimal without trailing zeroes
- How to convert string to float?
- What is the difference between Convert.ToInt32 and (int)?
- Limiting double to 3 decimal places
- Float/double precision in debug/release modes
- String to decimal conversion: dot separation instead of comma
- Type result with conditional operator in C#
- C++ floating point to integer type conversions
- Does one double promote every int in the equation to double?
- Why am I getting a compile error when multiplying a decimal by a literal value?
- How to round decimal value up to nearest 0.05 value?
- What’s the best way to represent System.Decimal in Protocol Buffers?
- How to get floats value without including exponential notation
- Cannot implicitly convert type ‘customtype’ to ‘othercustomtype’
- double minus double giving precision problems