// //------------------ DOK FILE -------------------------------------------------- +Header floatLib =pkg bios =title Floats =short floating numbers and vectors =desc Floating numbers and vectors // // //------------------ PROTO ----------------------------------------------------- strFloat +Proto strFloat =type fun Float -> Str =mode function =pkg bios =impl native =link =desc This function returns an 8-bytes string which encodes the floating number value in a binary way. It is a way to serialize a floating number that you can store in a file or send through a socket. The opposite function is [[strReadFloat]], it allows to recover the initial float number. > strFloat (3.1415) >-> Str: "l\\$12\\$83\\$c0\\$ca!\\t@" // +arg value =type Float =desc A floating number // +arg result =type Str =desc A 8-bytes string // // //------------------ PROTO ----------------------------------------------------- intFromFloat +Proto intFromFloat =type fun Float -> Int =mode function =pkg bios =impl native =link =desc This function returns a rounded integer, the nearest toward 0. > intFromFloat (1.2) >-> Int: 1 (0x1) > intFromFloat (1.8) >-> Int: 1 (0x1) > intFromFloat (-1.2) >-> Int: -1 (0xFFFFFFFFFFFFFFFF) > intFromFloat (-1.8) >-> Int: -1 (0xFFFFFFFFFFFFFFFF) // +arg value =type Float =desc A floating number // +arg result =type Int =desc An integer // // //------------------ PROTO ----------------------------------------------------- strFromFloat +Proto strFromFloat =type fun Float -> Str =mode function =pkg bios =impl native =link =desc This function returns the decimal representation of a floating number value. > strFromFloat (3.14) >-> Str: "3.14" > strFromFloat (3.) >-> Str: "3" // +arg value =type Float =desc A floating value // +arg result =type Str =desc A string encoding a decimal number // // //------------------ PROTO ----------------------------------------------------- floatsFromArray +Proto floatsFromArray =type fun array Float -> Floats =mode function =pkg bios =impl native =link =desc This function returns a vector of floats from an array of floats. Vectors of floats are made of 32-bits floating numbers, when Minimacy floating numbers use 64 bits. Vectors of floats are used in OpenGL. // +arg src =type array Float =desc An array of floats // +arg result =type Floats =desc A vector of floats // // //------------------ PROTO ----------------------------------------------------- floatsGet +Proto floatsGet =type fun Floats Int -> Float =mode function =pkg bios =impl native =link =desc This function reads the floating number at position index in the vector src. Remember that vectors of floats have 32 bits floats, when Minimacy floats are 64 bits. This will lead to a small difference between the floating numbers you gave to the [[floatsFromArray]] function, and the floats returned by [[floatsGet]]. // +arg src =type Floats =desc A vector of floats // +arg index =type Int =desc An index in src // +arg result =type Float =desc A floating number // // //------------------ PROTO ----------------------------------------------------- floatsLength +Proto floatsLength =type fun Floats -> Int =mode function =pkg bios =impl native =link =desc This function returns the length of the vector of floats src. // +arg src =type Floats =desc A vector of floats // +arg result =type Int =desc An integer // // //------------------ PROTO ----------------------------------------------------- floor +Proto floor =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the usual floor function on floating numbers. > floor (3.14) >-> Float: 3 > floor (-3.14) >-> Float: -4 // +arg value =type Float =desc A floating number // +arg result =type Float =desc The corresponding floor value // // //------------------ PROTO ----------------------------------------------------- exp +Proto exp =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'exponential'. // +arg value =type Float =desc A floating number // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- e +Proto e =type Float =mode constant =pkg bios =impl native =link =desc The mathematical constant 'e' > e >-> Float: 2.71828 // // //------------------ PROTO ----------------------------------------------------- cos +Proto cos =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'cosine'. // +arg value =type Float =desc A radian // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- cosh +Proto cosh =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'hyperbolic cosine'. // +arg value =type Float =desc A floating number // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- Float +Proto Float =type Float =mode type =pkg bios =impl native =link =desc This is the type of floating numbers in Minimacy. It is possible to define a string in the Minimacy syntax: the number must include at least one point. > 1.23 >-> Float: 1.23 > -1.23 >-> Float: -1.23 > 1. >-> Float: 1 // // //------------------ PROTO ----------------------------------------------------- Floats +Proto Floats =type Floats =mode type =pkg bios =impl native =link =desc This is the type of vectors of floating numbers. Vectors of floats are used in OpenGL. Their floats are only 32bits long, while Minimacy floats are 64 bits. // // //------------------ PROTO ----------------------------------------------------- absf +Proto absf =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'abs'. // +arg value =type Float =desc A floating number // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- acos +Proto acos =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'arc cosine'. // +arg value =type Float =desc A floating number // +arg result =type Float =desc A radian // // //------------------ PROTO ----------------------------------------------------- asin +Proto asin =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'arc sine'. // +arg value =type Float =desc A floating number // +arg result =type Float =desc A radian // // //------------------ PROTO ----------------------------------------------------- atan2 +Proto atan2 =type fun Float Float -> Float =mode function =pkg bios =impl native =link =desc This function returns the radian angle between the half line [Ox) and the half line [OM) where M has coordinates (x,y). // +arg y =type Float =desc A floating number // +arg x =type Float =desc Another floating number // +arg result =type Float =desc A radian // // //------------------ PROTO ----------------------------------------------------- atan +Proto atan =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'arc tangent'. // +arg value =type Float =desc A floating number // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- ceil +Proto ceil =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'ceil'. // +arg value =type Float =desc A floating number // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- ln +Proto ln =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'natural logarithm'. // +arg value =type Float =desc A floating number // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- log +Proto log =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'base 10 logarithm'. // +arg value =type Float =desc A floating number // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- maxf +Proto maxf =type fun Float Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'max'. // +arg a =type Float =desc A floating number // +arg b =type Float =desc Another floating number // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- minf +Proto minf =type fun Float Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'min'. // +arg a =type Float =desc A floating number // +arg b =type Float =desc Another floating number // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- pi +Proto pi =type Float =mode constant =pkg bios =impl native =link =desc The mathematical constant 'pi' > pi >-> Float: 3.14159 // // //------------------ PROTO ----------------------------------------------------- round +Proto round =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'round'. > round (1.2) >-> Float: 1 > round (1.6) >-> Float: 2 > round (1.5) >-> Float: 1 > round (-1.2) >-> Float: -1 > round (-1.6) >-> Float: -2 > round (-1.5) >-> Float: -2 > round (nil) >-> Float: 0 // +arg value =type Float =desc A floating number // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- sin +Proto sin =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'sine'. // +arg value =type Float =desc A radian // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- sinh +Proto sinh =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'hyperbolic sine'. // +arg value =type Float =desc A floating number // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- sqr +Proto sqr =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'square'. Do not mix up with [[sqrt]] (square root). // +arg value =type Float =desc A floating number // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- sqrt +Proto sqrt =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'square root'. // +arg value =type Float =desc A floating number // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- tan +Proto tan =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'tangent'. // +arg value =type Float =desc A radian // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- tanh +Proto tanh =type fun Float -> Float =mode function =pkg bios =impl native =link =desc This is the mathematical function 'hyperbolic tangent'. // +arg value =type Float =desc A floating number // +arg result =type Float =desc // // //------------------ PROTO ----------------------------------------------------- isInf +Proto isInf =type fun Float -> Bool =mode function =pkg bios =impl native =link =desc This function returns true if the provided floating number is infinite. > isInf (1./.0.) >-> Bool: true // +arg value =type Float =desc A floating number // +arg result =type Bool =desc A boolean // // //------------------ PROTO ----------------------------------------------------- isNan +Proto isNan =type fun Float -> Bool =mode function =pkg bios =impl native =link =desc This function returns true if the provided floating number is not a number. > isNan (sqrt (-2.)) >-> Bool: true // +arg value =type Float =desc A floating number // +arg result =type Bool =desc A boolean