Looking for an easier way to use float in C #

For a number of reasons, I should use float in my code instead of two-local ones. To use a literal in my code, I have to write something like:

float f = 0.75F;

or the compiler will be barf, since it only treats "0.75" as double. Is there anything that I can put into my code or install in Visual Studio that will make it treat the literal as “0.75” as floating without having to add “F” every time?

+3
source share
6 answers

Float comes with F :-)

0
source

No - fortunately, IMO. Literals are treated the same everywhere.

- , . "0.75" " , # - !" , float? " .

"F" ? ? , "F-suffixed" .

+14

. - .

, , , , .

, # 3, :

var f = 0.75F;

, F , .

+1
+1

var meaning = 1f;

"var" .

0

- , , double float , double float, ( ) , , , . float double ( , "" , ), , , ''.

, Microsoft double float? , , double, .

0

Source: https://habr.com/ru/post/1713058/


All Articles