C# How to format a double to one decimal place without rounding

后端 未结 6 1363

I need to format a double value to one decimal place without it rounding.

double value = 3.984568438706
string result = \"\";

What I have tried

6条回答
  •  鱼传尺愫
    2021-02-18 15:50

    Just use modulo operator + built in ToString:

    result = (value - (value % 0.1)).ToString("N1") + "%";
    

提交回复
热议问题