Convert numbers to and from base 60
The Sexagesimal Converter translates decimal integers into base-60 notation and back. Base 60 is the system the Babylonians used for astronomy and accounting, and it is the reason an hour has 60 minutes and a circle has 360 degrees. Each base-60 digit is written as an ordinary number from 0 to 59, with positions separated by commas.
How it works
Converting a decimal integer to sexagesimal is repeated division by 60:
while v > 0:
digit = v mod 60 (a value 0..59)
v = floor(v / 60)
The digits are collected from least significant to most significant, then reversed. To convert back, evaluate the digits left to right with total = total × 60 + digit, after checking that every digit is a valid 0–59 value. A group of 60 or more is rejected, because it would not be a single legal position.
Example
The value 3661 — one hour, one minute and one second — divides as 3661 = 1×3600 + 1×60 + 1, giving the sexagesimal form 1,1,1. Likewise 3600 alone is 1,0,0, exactly how a clock would show one hour. The comma notation keeps each large digit readable without inventing 60 separate symbols.
Notes
This converter works with whole numbers; the fractional sexagesimal used for arcseconds and clock fractions extends the same idea with a radix point. Negative inputs are supported and simply carry a leading minus sign.