IDEAS home Printed from https://ideas.repec.org/p/hal/journl/hal-04346335.html
   My bibliography  Save this paper

Euclidean Affine Functions and their Application to Calendar Algorithms

Author

Listed:
  • Cassio Neri
  • Lorenz Schneider

    (EM - EMLyon Business School)

Abstract

"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."

Suggested Citation

  • Cassio Neri & Lorenz Schneider, 2023. "Euclidean Affine Functions and their Application to Calendar Algorithms," Post-Print hal-04346335, HAL.
  • Handle: RePEc:hal:journl:hal-04346335
    Note: View the original document on HAL open archive server: https://hal.science/hal-04346335
    as

    Download full text from publisher

    File URL: https://hal.science/hal-04346335/document
    Download Restriction: no
    ---><---

    Corrections

    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:hal:journl:hal-04346335. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    We have no bibliographic references for this item. You can help adding them by using this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: CCSD (email available below). General contact details of provider: https://hal.archives-ouvertes.fr/ .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.