Pfarah


Utils

Namespace: Pfarah

Functions and values

Function or valueDescription
cut n
Signature: n:int -> float

Converts an integer that represents a Q16.16 fixed-point number into its floating point representation. See: https://en.wikipedia.org/wiki/Q_(number_format)

cut32 n
Signature: n:int -> float

Converts the smaller precision binary float from the integer it is stored as to a float. It makes sense to be encoded this way as the numbers are textually represented with three decimal points (#.000)

encoding
Signature: Encoding
parseDate str strLength
Signature: str:byte [] -> strLength:int -> Nullable<DateTime>

Attempts to convert the string to a date time. Returns some datetime if successful

parseDouble str strLength
Signature: str:byte [] -> strLength:int -> Nullable<double>

A highly optimized version of Double.TryParse that takes advantage of the fact that we know that the number format is (in regex form): <(\d+)\.(\d{1,3,5})?>. In profiling it was shown that Double.TryParse was a bottleneck at around 20-50% of the CPU time and after this function was written, the bottleneck completely disappeared.

tryDateParse str
Signature: str:string -> DateTime option

Attempts to convert a given string of the form yyyy.mm.dd with and optional hour part into a proper DateTime.

tryDoubleParse str
Signature: str:string -> double option

Attempts to convert a given string into a number that either has no fractional part, 3 decimal, or 5 decimal points.

Fork me on GitHub