In C++ float value being truncated from double

后端 未结 4 938
南旧
南旧 2021-01-27 22:59

I\'ve coded using float variables before and never had this problem.

float  a, b, subtotal, stx;
a=15.95;
b=24.95;
subtotal=a+b;
stx=subtotal*.07;

cout <         


        
4条回答
  •  爱一瞬间的悲伤
    2021-01-27 23:29

    From standard 2.14.4

    The type of a floating literal is double unless explicitly specified by a suffix.

    (emphasis mine)

提交回复
热议问题