1/2
does integer division, its result is 0
, change either or both operand to double
, e.g:
1.0/2
More Related Contents:
- Why does >= operator work as > operator in C when compared with 0.9 [duplicate]
- Correct format specifier for double in printf
- ‘float’ vs. ‘double’ precision
- How to get the sign, mantissa and exponent of a floating point number
- How to compare double numbers?
- What’s the use of suffix `f` on float value
- Simd matmul program gives different numerical results
- How to convert string to float?
- Floating point comparison `a != 0.7` [duplicate]
- How to extract the decimal part from a floating point number in C?
- C: printf a float value
- C: Casting minimum 32-bit integer (-2147483648) to float gives positive number (2147483648.0)
- Are floating point operations in C associative?
- Convert double/float to string
- Ranges of floating point datatype in C?
- Precision in C floats
- My floating point number has extra digits when I print it
- Is there a function to round a float in C or do I need to write my own?
- Is my fma() broken?
- C – Serialization of the floating point numbers (floats, doubles)
- C: How to wrap a float to the interval [-pi, pi)
- Variadic function (va_arg) doesn’t work with float?
- sin, cos, tan and rounding error
- Why does printf print random value with float and integer format specifier
- What precisely does the %g printf specifier mean?
- C Function to Convert float to byte array
- Can a conversion from double to int be written in portable C
- clang 14.0.0 floating point optimizations
- Conditional tests in primality by trial division
- How to produce a NaN float in c?