f# - 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 部分有关,但是我尝试过的任何方法都不起作用,而且我没有运气找到任何可以提供帮助的示例。我能做些什么?
解决方案
好的,我刚刚发现问题是我使用的是 %d 而不是 %f
推荐阅读
- java - android的清单文件发生了什么?
- haskell - 在 Haskell 中将原始二进制文件写入文件?
- android - 底部元素使用 AppBarLayout 在导航栏后面绘制元素
- python-3.x - Panda lambda TypeError object float no len()
- objective-c - [__NSArrayM addObjectsFromArray:]:消息发送到已释放实例 0x283e8c990 - Apprtc
- javascript - 为什么我的日期增加 2 天而我只给出值 1
- ios - 类型“ChatViewController”没有成员“showOrHideKeyboard”
- elasticsearch - 用于 Golang 的 Olivere 包中的 BulkIndexer 以替换 Elastigo
- azure - 使用应用程序网关入口控制器时可以配置 SSL 卸载吗?
- android - 单击通知组不会重定向到特定屏幕,而不是在 oreo 中重新启动该应用程序