C#:如何正确处理 float

标签 c#

在我的代码中,我写了以下行:

return ((value / 120) * 1440).ToString();

现在,当 value 中的值小于零时,它会返回 0,因为它将 (value/120) 的结果视为整数,而我需要 C#将此结果视为 float 有什么方法可以实现吗?

例子: 如果值 = 80

然后, 此函数返回 0 而我希望此函数返回 960

最佳答案

return ((value / 120.0) * 1440).ToString();

关于C#:如何正确处理 float ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6212091/

相关文章:

c# - System.NotSupportedException - 无法比较“System.Linq.IQueryable”类型的元素

c# - 存储过程错误 "argument 1 for routine ... is not a variable or NEW pseudo-variable in BEFORE trigger"

c# - 带有 ASP.NET MVC 的 C# 中的通知系统/服务

C#.Net 邮件将进入垃圾邮件文件夹

c# 如何在表单加载之前阻止 "CheckBox CheckedChanged"触发?

c# - 添加Unity DI框架,现在报错 "The type UmbracoAuthorizeAttribute has multiple constructors of length 1. Unable to disambiguate."

c# - Entity Framework 代码优先 6.0 : is there any annotations to add index to a column(s)

c# - 如何在 ASP.Net 页面使用 C# 常量?

c# - 验证多个电子邮件列表

c# - 如何在 Visual Studio 2010 中将项目输出平台设置为 x86