E
E
Evgeny Romashkan2018-09-01 21:35:13
C++ / C#
Evgeny Romashkan, 2018-09-01 21:35:13

Why complains about double > float conversion?

I do not understand where double is taken here?
5b8adbd6640fd837520304.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
res2001, 2018-09-02
@EvgeniiR

double you have constants in the expression. By default real constants are double. Therefore, all other components of the expression are converted to double, and when assigned, it is necessary to convert again to float with loss of precision, and the compiler informs about this.
To make constants float, you need to use the 'f' suffix: 9.0f. Then the entire expression will be evaluated to float.

D
Dmitry, 2018-09-01
@demon416nds

appears when multiplying or dividing
to save the result as accurately as possible,
IMHO, you should not bother

P
Pavlo Ponomarenko, 2018-09-02
@TheShock

I think it will be solved if we replace the type of variables fahr and celsius from float to double.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question