简体   繁体   中英

How to get numbers after comma in F#

I want to get 4 numbers after comma in F# : This is my code :

// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.

open System

[<EntryPoint>]
let main argv = 

    let num = Console.ReadLine() |> float
    Console.WriteLine(num)

    Console.Read() |>ignore
    0

And this's result :

open System

[<EntryPoint>]
let main argv = 

    let num = Math.Round(Console.ReadLine() |> float, 3) 
    Console.WriteLine(num)

    Console.Read() |>ignore
    0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM