F # Learning Notes (integer and real number operations)

Source: Internet
Author: User
Tags bitwise operators mathematical functions

In F #, the symbols =,<>,<,>,<= and >= represent equal, not equal to, less than, greater than, less than, and greater than or equal to, respectively.

F # provides 6 bitwise operators: ~ ~ ~ (Fetch),&&& (with), | | | (or), ^^ ^ (XOR),<<< (left shift),>>> (right Shift)

Common mathematical functions:

extremum function max,min integers and real numbers

Absolute value function abs integers and real numbers

Rounding function Ceil,floor,round Real number

exponential function exp,** real numbers

Trigonometric Sin,cos,tan,asin,acos,atan,sinh,cosh,tanh Real numbers

F # also provides a truncation function, which always truncates the decimal portion of the truncate

For large number operations, F # provides bigint and Bignum

Here is an expression that evaluates:

[<entrypoint>]let main argv=Let Eva (s:string) =Let SS= S.trim (). Split (' ') Let X= ss.[0] |>System.Double.Parse let y= ss.[2] |>System.Double.Parse Match ss.[1] with|"+"-X +y|"-"-X-y|"*"X *y|"/"-X/y|"%"X%y|"**"-X * *y| _,0.0PRINTFN"Please enter an expression:"Let s=System.Console.ReadLine ()ifS.trim (). Split (' '). Length <2Then PRINTFN"expression is not well-formed"    ElseS |> Eva |> printfn"=%f"    0 //returns an integer exit code

F # Learning Notes (integer and real number operations)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.