2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1 +1,3 @@
;Task:
Demonstrate how to specify the minimum size of a variable or a data type.
<br><br>

View file

@ -0,0 +1,16 @@
import Data.Int
import Foreign.Storable
task name value = putStrLn $ name ++ ": " ++ show (sizeOf value) ++ " byte(s)"
main = do
let i8 = 0::Int8
let i16 = 0::Int16
let i32 = 0::Int32
let i64 = 0::Int64
let int = 0::Int
task "Int8" i8
task "Int16" i16
task "Int32" i32
task "Int64" i64
task "Int" int

View file

@ -0,0 +1,40 @@
EnableExplicit
Structure AllTypes
b.b
a.a
w.w
u.u
c.c ; character type : 1 byte on x86, 2 bytes on x64
l.l
i.i ; integer type : 4 bytes on x86, 8 bytes on x64
q.q
f.f
d.d
s.s ; pointer to string on heap : pointer size same as integer
z.s{2} ; fixed length string of 2 characters, stored inline
EndStructure
If OpenConsole()
Define at.AllTypes
PrintN("Size of types in bytes (x64)")
PrintN("")
PrintN("byte = " + SizeOf(at\b))
PrintN("ascii = " + SizeOf(at\a))
PrintN("word = " + SizeOf(at\w))
PrintN("unicode = " + SizeOf(at\u))
PrintN("character = " + SizeOf(at\c))
PrintN("long = " + SizeOf(at\l))
PrintN("integer = " + SizeOf(at\i))
PrintN("quod = " + SizeOf(at\q))
PrintN("float = " + SizeOf(at\f))
PrintN("double = " + SizeOf(at\d))
PrintN("string = " + SizeOf(at\s))
PrintN("string{2} = " + SizeOf(at\z))
PrintN("---------------")
PrintN("AllTypes = " + SizeOf(at))
PrintN("")
PrintN("Press any key to close the console")
Repeat: Delay(10) : Until Inkey() <> ""
CloseConsole()
EndIf