Skip to content

Commit

Permalink
Add Section 02 12: Summary of the basic types.
Browse files Browse the repository at this point in the history
  • Loading branch information
eminencegrs committed Feb 4, 2024
1 parent f9bd885 commit 35ebe8c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/FPinFSharp.Exercises/Chapter_02/Section_02_12.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace FPinFSharp.Exercises.Chapter_02

// 2.12 Summary of the basic types
module Section_02_12 =

let getChar () : char = 'c'

let getByte isHex : byte =
match isHex with
| true -> 0xFFuy
| false -> 255uy

let getSByte isHex : sbyte =
match isHex with
| true -> -0x80y
| false -> 127y

let getInt16 isHex : int16 =
match isHex with
| true -> -0x8000s
| false -> 32767s

let getUInt16 isHex : uint16 =
match isHex with
| true -> 0xFFFFus
| false -> 65535us

let getInt32 isHex : int32 =
match isHex with
| true -> -0x80000000
| false -> 2147483647

let getUInt32 isHex : uint32 =
match isHex with
| true -> 0xFFFFFFFFu
| false -> 4294967295u
1 change: 1 addition & 0 deletions src/FPinFSharp.Exercises/FPinFSharp.Exercises.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<Compile Include="Chapter_02\Section_02_09.fs" />
<Compile Include="Chapter_02\Section_02_10.fs" />
<Compile Include="Chapter_02\Section_02_11.fs" />
<Compile Include="Chapter_02\Section_02_12.fs" />
<Content Include="Chapter_03\Description.md" />
</ItemGroup>

Expand Down

0 comments on commit 35ebe8c

Please sign in to comment.