Skip to content

Fast and lightweight fixed-decimal number type for Swift. Provides precise fractional calculations without floating-point rounding errors. Ideal for financial and small-scale numeric computations where accuracy and performance matter.

Notifications You must be signed in to change notification settings

metatronsw/FDec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FDec

A fixed point decimal number format for Swift.

Extremely fast numerical structure for precise decimal fraction calculations. Sacrificing size and the dynamic capabilities of float, you get an easy-to-use fast and simple but accurate calculation. Suitable for finance and small calculations. The number of decimals is fixed in the Structure variable, so mixing the sizes is not recommended, but it can be done. This needs special attention, but in return a piece of Int value takes up space in memory.

	FDec.decimalPlaces = 3

	let a = FDec("32.001")
	let b = FDec(287.123)

	print(a+b) // 319.124

Unlike Decimal, FDec can be easily serialized as a single integer in JSON files, making storage and data transfer simple and efficient. It is particularly well-suited for databases like SQLite and MySQL, enabling fast storage, retrieval, and numeric searches. Ideal for financial and small-scale numeric computations where accuracy, performance, and compatibility matter.

About

Fast and lightweight fixed-decimal number type for Swift. Provides precise fractional calculations without floating-point rounding errors. Ideal for financial and small-scale numeric computations where accuracy and performance matter.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages