Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add other way to declare number type F# #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ Let's look at some primitive types:

Both Rust and F# use postfixes on numbers to indicate the type if you want to choose something besides the default 32-bit int or 64-bit float. In Rust you can choose either declaring the type or adding a postfix, while in F# it's the postfix that does it. Thus:

* Rust `let x: u8 = 5` or `let x = 5u8` is F# `let x = 5uy`. (**u**nsigned b**y**te)
* Rust `let x: u16 = 5` or `let x = 5u16` is F# `let x = 5us`. (**u**nsigned **s**hort)
* Rust `let x: u32 = 5` or `let x = 5u32` is F# `let x = 5u`. (**u**nsigned)
* Rust `let x: u64 = 5` or `let x = 5u64` is F# `let x = 5UL`. (**U**nsigned **L**ong)
* Rust `let x: i8 = 5` or `let x = 5i8` is F# `let x = 5y`. (b**y**te)
* Rust `let x: i16 = 5` or `let x = 5i16` is F# `let x = 5s`. (**s**hort)
* Rust `let x: i32 = 5` or `let x = 5i32` is F# `let x = 5`. (no postfix here - it's the default)
* Rust `let x: i64 = 5` or `let x = 5i64` is F# `let x = 5L`. (**L**ong)
* Rust `let x: f32 = 5.0` or `let x = 5.0f32` is F# `let x = 5.0f` or `let x = 5f`.
* Rust `let x: f64 = 5.0` or `let x = 5.0f64` is F# `let x = 5.0`. (no postfix here - it's the default)
* Rust `let x: u8 = 5` or `let x = 5u8` is F# `let x = uint8 5` or `let x = 5uy`. (**u**nsigned b**y**te)
* Rust `let x: u16 = 5` or `let x = 5u16` is F# `let x = uint16 5` or `let x = 5us`. (**u**nsigned **s**hort)
* Rust `let x: u32 = 5` or `let x = 5u32` is F# `let x = uint32 5` or `let x = 5u`. (**u**nsigned)
* Rust `let x: u64 = 5` or `let x = 5u64` is F# `let x = uint64 5` or `let x = 5UL`. (**U**nsigned **L**ong)
* Rust `let x: i8 = 5` or `let x = 5i8` is F# `let x = int8 5` or `let x = 5y`. (b**y**te)
* Rust `let x: i16 = 5` or `let x = 5i16` is F# `let x = int16 5` or `let x = 5s`. (**s**hort)
* Rust `let x: i32 = 5` or `let x = 5i32` is F# `let x = int32 5` or `let x = 5`. (no postfix here - it's the default)
* Rust `let x: i64 = 5` or `let x = 5i64` is F# `let x = int64 5` or `let x = 5L`. (**L**ong)
* Rust `let x: f32 = 5.0` or `let x = 5.0f32` is F# `let x = float32 5` or `let x = 5.0f` or `let x = 5f`.
* Rust `let x: f64 = 5.0` or `let x = 5.0f64` is F# `let x = float 5` or `let x = 5.0`. (no postfix here - it's the default)

And both Rust and F# have the option of putting _ in between numbers to make them readable. This code works in both languages:

Expand Down