From eb2fa48887faa32edd42bf1ccf2da6dd2aae2d44 Mon Sep 17 00:00:00 2001 From: preciz Date: Fri, 25 Sep 2026 21:25:55 +0200 Subject: [PATCH] Calculate Calendar.ISO.quarter_of_year/3 with bitwise arithmetic Replace `div(month - 1, 3) + 1` with `(month * 5 + 14) >>> 4` for months 1..12 to avoid hardware integer division. Assisted-by: Antigravity:Gemini 3.8 Flash --- lib/elixir/lib/calendar/iso.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/elixir/lib/calendar/iso.ex b/lib/elixir/lib/calendar/iso.ex index 7cd4fa9168..4d24ff010d 100644 --- a/lib/elixir/lib/calendar/iso.ex +++ b/lib/elixir/lib/calendar/iso.ex @@ -1198,7 +1198,7 @@ defmodule Calendar.ISO do @impl true def quarter_of_year(year, month, day) when is_year(year) and is_month(month) and is_day(day) do - div(month - 1, 3) + 1 + (month * 5 + 14) >>> 4 end @doc """