首页 > 解决方案 > F# 控制台无法识别十进制值

问题描述

我是第一次练习 F#,我想我会尝试制作一个程序来计算不同形状的面积。但是,找到圆面积的部分给我带来了很多麻烦。enter code here

elif stringInput = "2" then
let PI = 3.14156
printfn "What is the circle's radius: "
let radiusString = System.Console.ReadLine()
let radiusInt = radiusString |> float
let cirlceArea = (radiusInt * radiusInt) * PI

printfn "The area of the circle is : %d" cirlceArea

我确定它与代码的 radiusString |> float 部分有关,但是我尝试过的任何方法都不起作用,而且我没有运气找到任何可以提供帮助的示例。我能做些什么?

标签: f#decimal

解决方案


好的,我刚刚发现问题是我使用的是 %d 而不是 %f


推荐阅读