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 a Decimal to a 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#
- Difference between decimal, float and double in .NET?
- Why is floating point arithmetic in C# imprecise?
- How can I divide two integers to get a double?
- Setting a property by reflection with a string value
- C# Float expression: strange behavior when casting the result float to int
- Casting a result to float in method returning float changes result
- Is the behaviour of casting a negative double to unsigned int defined in the C standard? Different behaviour on ARM vs. x86
- What does the M stand for in C# Decimal literal notation?
- Understanding floating point problems
- double or float, which is faster? [duplicate]
- How to change symbol for decimal point in double.ToString()?
- Fast way to convert a two dimensional array to a List ( one dimensional )
- Arbitrary-Precision Decimals in C# [duplicate]
- Invalid cast from ‘System.Int32’ to ‘System.Nullable`1[[System.Int32, mscorlib]]
- Is there any generic Parse() function that will convert a string to any type using parse?
- Raising a decimal to a power of decimal?
- Why does “dtoa.c” contain so much code?