Euclidean Affine Functions and their Application to Calendar Algorithms - Archive ouverte HAL Accéder directement au contenu
Article Dans Une Revue Software: Practice and Experience Année : 2023

Euclidean Affine Functions and their Application to Calendar Algorithms

Cassio Neri
  • Fonction : Auteur

Résumé

"In everyday life, dates are specified in terms of year, month and day, but this is not how digital devices represent them. Such devices continuously count elapsed days since a certain reference date, usually 1 January 1970. Accordingly, the date exactly one year after this reference is 1 January 1971 and digital devices represent it as 365. Conversions between machine and human formats are, arguably, amongst the most common operations performed by digital devices and constitute the subject of this article. We introduce Euclidean affine functions (EAFs) and study their properties. EAFs are of the form f(n) = (a.n+b)/d , where n, a, b, and d are integers and where denotes the quotient of Euclidean division. We derive algebraic relations and numerical approximations that are important for the efficient evaluation of these expressions in modern CPUs. Since division is a particular case of an EAF (when a = 1 and b = 0 ), the optimisations proposed in this article can also be applied to division. The main application presented in this article is the derivation of conversion algorithms for the Gregorian calendar. We will show that they can be implemented substantially more efficiently than is currently the case in widely used C, C++, C#, and Java open source libraries. Gains in speed of a factor of two or more are common. These algorithms have been implemented in GCC, the Linux Kernel and .NET."
Fichier principal
Vignette du fichier
741218-Softw Pract Exp - 2022 - Neri - Euclidean affine functions and their application to calendar algorithms.pdf (2.95 Mo) Télécharger le fichier
Origine Fichiers produits par l'(les) auteur(s)

Dates et versions

hal-04346335 , version 1 (15-12-2023)

Identifiants

  • HAL Id : hal-04346335 , version 1

Citer

Cassio Neri, Lorenz Schneider. Euclidean Affine Functions and their Application to Calendar Algorithms. Software: Practice and Experience, 2023, 53 (4), pp.937-970. ⟨hal-04346335⟩

Collections

EMLYON
11 Consultations
16 Téléchargements

Partager

Gmail Mastodon Facebook X LinkedIn More