RU2615336C1 - Method for encoding and computing date using simplified format in digital devices - Google Patents
Method for encoding and computing date using simplified format in digital devices Download PDFInfo
- Publication number
- RU2615336C1 RU2615336C1 RU2016114982A RU2016114982A RU2615336C1 RU 2615336 C1 RU2615336 C1 RU 2615336C1 RU 2016114982 A RU2016114982 A RU 2016114982A RU 2016114982 A RU2016114982 A RU 2016114982A RU 2615336 C1 RU2615336 C1 RU 2615336C1
- Authority
- RU
- Russia
- Prior art keywords
- date
- div
- integer
- mod
- year
- Prior art date
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q10/00—Administration; Management
- G06Q10/10—Office automation; Time management
- G06Q10/109—Time management, e.g. calendars, reminders, meetings or time accounting
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F17/00—Digital computing or data processing equipment or methods, specially adapted for specific functions
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F7/00—Methods or arrangements for processing data by operating upon the order or content of the data handled
- G06F7/38—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Business, Economics & Management (AREA)
- Human Resources & Organizations (AREA)
- Data Mining & Analysis (AREA)
- Entrepreneurship & Innovation (AREA)
- Strategic Management (AREA)
- General Engineering & Computer Science (AREA)
- General Business, Economics & Management (AREA)
- Mathematical Analysis (AREA)
- Quality & Reliability (AREA)
- Operations Research (AREA)
- Marketing (AREA)
- Computational Mathematics (AREA)
- Computing Systems (AREA)
- Tourism & Hospitality (AREA)
- Mathematical Optimization (AREA)
- Pure & Applied Mathematics (AREA)
- Economics (AREA)
- Databases & Information Systems (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Complex Calculations (AREA)
Abstract
Description
Область техники, к которой относится изобретениеFIELD OF THE INVENTION
Предлагаемое изобретение относится к вычислительной технике и, в частности, к способам кодирования и преобразования даты для хранения и использования в цифровых устройствах: компьютерах, терминалах и пр.The present invention relates to computer technology and, in particular, to methods for encoding and converting dates for storage and use in digital devices: computers, terminals, etc.
Уровень техникиState of the art
В современных цифровых устройствах для хранения и использования даты и времени применяются различные внутренние форматы данных. Для преобразования из внутреннего формата во внешний и наоборот требуется проведение ряда вычислений и операций кодирования/декодирования.In modern digital devices, various internal data formats are used to store and use the date and time. To convert from an internal format to an external one and vice versa, a number of calculations and encoding / decoding operations are required.
Так, известен способ кодирования и преобразования даты в программном обеспечении (ПО) SQL Server 2005 и SQL Server 2012 компании Microsoft [1, 2]. Для хранения даты и времени отводится два 4-байтовых целых числа (всего используется 8 байт). Первые 4 байта используются для хранения собственно даты и содержат количество дней до или после даты отсчета, в качестве которой выбрано 1 января 1900 года (для типа данных datetime; вторые 4 байта содержат текущее значение времени, представленного в виде трехсотых долей секунды, прошедших после полуночи). Используется также хранение даты и времени с меньшей точностью. В этом варианте даты хранятся в виде 2-байтового целого числа, представляющего количество дней, прошедших с 1 января 1900 года (для типа данных smalldatetime; в двух следующих байтах хранится количество минут, прошедших после полуночи).Thus, a known method of encoding and converting dates in software (software) SQL Server 2005 and SQL Server 2012 from Microsoft [1, 2]. To store the date and time, two 4-byte integers are allocated (a total of 8 bytes are used). The first 4 bytes are used to store the actual date and contain the number of days before or after the reference date, which was selected on January 1, 1900 (for the datetime data type; the second 4 bytes contain the current time value, presented in the form of three hundredths of a second after midnight ) Storage of date and time is also used with less accuracy. In this option, dates are stored as a 2-byte integer representing the number of days elapsed from January 1, 1900 (for the data type smalldatetime; the next two bytes store the number of minutes elapsed after midnight).
Таким образом, дата может храниться в виде целого числа и минимально занимать 2 байта (16 бит).Thus, the date can be stored as an integer and occupy at least 2 bytes (16 bits).
Для прямого преобразования даты по григорианскому календарю в содержимое ячейки памяти может использоваться следующий алгоритм [3]:To directly convert the date according to the Gregorian calendar to the contents of a memory cell, the following algorithm can be used [3]:
a=(М-14) div 12,a = (M-14) div 12,
y=Y+4800-а,y = Y + 4800-a,
m=M+12×а-3,m = M + 12 × a-3,
J=D+(153×m+2)div 5+365×y+у div 4-у div 100+у div 400-32075,J = D + (153 × m + 2) div 5 + 365 × y + div div 4 div 100 + div 400-32075,
где а, у, m - промежуточные переменные целого типа;where a, y, m are intermediate variables of integer type;
M - месяц года, от 1 (январь) до 12 (декабрь);M - month of the year, from 1 (January) to 12 (December);
D - день месяца, от 1 до 31;D - day of the month, from 1 to 31;
Y - год григорианского календаря.Y is the year of the Gregorian calendar.
После этого для получения N из полученного значения J (номер юлианского дня для исходной даты) вычитают константу J0, которая зависит от стартовой даты и является номером юлианского дня для стартовой даты. Однако для обратного преобразования целого числа N в дату используется еще большее количество преобразований и вычислений, сначала получают номер юлианского дня J, прибавляя константу J0, далее вычисляютAfter that, to obtain N from the obtained value J (Julian day number for the starting date), the constant J0 is subtracted, which depends on the starting date and is the Julian day number for the starting date. However, for the inverse transformation of the integer N to the date, an even greater number of conversions and calculations are used, first get the Julian day number J, adding the constant J0, then calculate
j=J+32044,j = J + 32044,
g=j div 146097,g = j div 146097,
dg=j mod 146097,dg = j mod 146097,
с=(dg div 36524+1)×3 div 4,c = (dg div 36524 + 1) × 3 div 4,
dc=dg-с×36524,dc = dg-s × 36524,
b=dc div1461,b = dc div1461,
db=dc mod 1461,db = dc mod 1461,
a=(db div 365+1) × 3 div 4,a = (db div 365 + 1) × 3 div 4,
da=db - a×365,da = db - a × 365,
у=g×400+с×100+b×4+a,y = g × 400 + s × 100 + b × 4 + a,
m=(da×5+308) div 153-2,m = (da × 5 + 308) div 153-2,
d=da-(m+4)×153 div 5+122,d = da- (m + 4) × 153 div 5 + 122,
Y=y-4800+(m+2) div 12,Y = y-4800 + (m + 2) div 12,
M=(m+2) mod 12+1,M = (m + 2) mod 12 + 1,
D=d+1,D = d + 1,
где b, c, d, j, g, da, db, dc, dg - промежуточные переменные целого типа.where b, c, d, j, g, da, db, dc, dg are intermediate variables of integer type.
Недостатками известного способа являются необходимость проводить ряд сложных вычислений и большой занимаемый объем хранимых данных.The disadvantages of this method are the need to carry out a number of complex calculations and a large occupied volume of stored data.
В ряде цифровых устройств возникает необходимость использования только даты, включающей год, месяц и день, что позволяет снизить объем хранимых данных и упростить вычисления.In a number of digital devices, the need arises to use only the date, including the year, month and day, which allows to reduce the amount of stored data and simplify calculations.
Для таких устройств может быть использован известный способ кодирования даты [4], заключающийся в том, чтоFor such devices, a known date encoding method [4] can be used, namely, that
- выделяют для хранения данных о дате, включающей год, месяц и день, целое число длиной К бит;- allocate for storing data about the date, including the year, month and day, an integer of length K bits;
- устанавливают для отсчета фиксированную дату как первое января определенного года Y0;- set a fixed date for the countdown as the first of January of a certain year Y0;
- вводят значения текущего года Y, месяца М, дня D;- enter the values of the current year Y, month M, day D;
- вычисляют целое число N для хранения данных о дате по формуле- calculate an integer N for storing date data according to the formula
N=D+(М-1)*32+(Y-Y0)*384;N = D + (M-1) * 32 + (Y-Y0) * 384;
- сохраняют число N в двоичном формате;- store the number N in binary format;
- вычисляют при необходимости дату по формулам- calculate, if necessary, the date by the formulas
D=N mod 32,D = N mod 32,
M=(N div 32) div 12+1,M = (N div 32) div 12 + 1,
Y=Y0+(N div 384),Y = Y0 + (N div 384),
где div - операция целочисленного деления (деления с отбрасыванием дробной части);where div is the operation of integer division (division with discarding the fractional part);
mod - операция взятия остатка от целочисленного деления.mod - operation to take the remainder of integer division.
Описанный способ принят за прототип.The described method is adopted as a prototype.
Недостатком известного способа является ограничение диапазона хранимых дат. Несмотря на то что способ выигрывает в простоте вычисления и компактности данных, часть возможных значений не используется.The disadvantage of this method is the limitation of the range of stored dates. Despite the fact that the method wins in the simplicity of calculation and compactness of the data, some of the possible values are not used.
Для сравнения рассмотрим возможный диапазон хранимых дат. В качестве первоначальной даты Y0 возьмем 01.01.1900 (1 января 1900 г. ). Размер даты 2 байта (16 бит).For comparison, consider a possible range of stored dates. As the initial date Y0, we take 01.01.1900 (January 1, 1900). The date size is 2 bytes (16 bits).
Если использовать способ компании Microsoft, когда дата вычисляется в днях от первоначальной даты, получаем конечную дату 06.06.2079. Если учитывать только полностью входящие годы, то 31.12.2078. Таким образом, данный способ обеспечивает максимально возможный диапазон в 179 лет.If you use the method of Microsoft, when the date is calculated in days from the original date, we get the end date 06/06/2079. If we consider only the completely incoming years, then 12/31/2078. Thus, this method provides the maximum possible range of 179 years.
Если использовать способ, принятый за прототип, то получаем максимальную дату 30.08.2070. Если учитывать только полностью входящие годы, то получаем 31.12.2069. В результате, обеспечивается диапазон в 170 лет. Данный способ содержит меньше вычислений, но приходится жертвовать частью значений, поэтому диапазон становится короче на 9 лет.If you use the method adopted for the prototype, then we get the maximum date 08/30/2070. If we consider only the completely incoming years, then we get 12/31/2069. As a result, a range of 170 years is ensured. This method contains fewer calculations, but some of the values have to be sacrificed, so the range becomes shorter by 9 years.
Раскрытие изобретенияDisclosure of invention
Техническим результатом является увеличение диапазона возможных значений даты.The technical result is to increase the range of possible date values.
Для этого предлагается способ, заключающийся в том, чтоFor this, a method is proposed, which consists in the fact that
- выделяют для хранения данных о дате, включающей год, месяц и день, целое число длиной K бит;- allocate for storing data about the date, including the year, month and day, an integer of length K bits;
- устанавливают для отсчета фиксированную дату как первое января определенного года Y0;- set a fixed date for the countdown as the first of January of a certain year Y0;
- вводят значения текущего года Y, месяца М, дня D;- enter the values of the current year Y, month M, day D;
- вычисляют целое число N для хранения данных о дате по формуле- calculate an integer N for storing date data according to the formula
N=D+М*31+(Y-Y0)*372-32;N = D + M * 31 + (Y-Y0) * 372-32;
- сохраняют число N в двоичном формате;- store the number N in binary format;
- вычисляют при необходимости дату по формулам- calculate, if necessary, the date by the formulas
D=((N mod 372) mod 31)+1,D = ((N mod 372) mod 31) +1,
M=((N mod 372) div 31)+1,M = ((N mod 372) div 31) +1,
Y=Y0+(N div 372),Y = Y0 + (N div 372),
где div - операция целочисленного деления (деления с отбрасыванием дробной части);where div is the operation of integer division (division with discarding the fractional part);
mod - операция взятия остатка от целочисленного деления.mod - operation to take the remainder of integer division.
В предложенном способе вычисляют целое число N для хранения данных о дате по формулеIn the proposed method, an integer N is calculated for storing date data according to the formula
N=D-1+(M-1)*31+(Y-Y0)*372.N = D-1 + (M-1) * 31 + (Y-Y0) * 372.
Значение N представляет собой количество дней от первоначальной даты.N is the number of days from the original date.
При вычислении N по приведенной формуле в качестве количества дней в любом месяце берется максимально возможное значение 31. Таким образом, каждая дата внутри года будет иметь свой постоянный порядковый номер от 1 (1 января) до 31*12=372 (31 декабря) независимо от того, был ли год високосный или нет. Смещение же между одним и тем же днем текущего и последующего месяца будет равно 31, а между датой текущего года и такой же датой последующего года будет равно 31 * 12=372. Лишние значения дней 30 февраля, 31 февраля или же 29 февраля для года, не являющегося високосным, не используются.When calculating N using the above formula, the maximum possible value of 31 is taken as the number of days in any month. Thus, each date within the year will have its own constant serial number from January 1 (January 1) to 31 * 12 = 372 (December 31), regardless whether the year was a leap year or not. The offset between the same day of the current and next month will be equal to 31, and between the date of the current year and the same date of the next year will be equal to 31 * 12 = 372. Extra days on February 30, February 31, or February 29 for a non-leap year are not used.
Сокращая запись для N, получаем окончательноReducing the entry for N, we finally get
N=D+М*31+(Y-Y0)*372-32.N = D + M * 31 + (Y-Y0) * 372-32.
Количество байт для хранения числа N остается таким же, как в прототипе (2 байта = 16 бит). Соответственно, максимально N содержит 216 = 65536 значений в диапазоне от 0 до 65535.The number of bytes for storing the number N remains the same as in the prototype (2 bytes = 16 bits). Accordingly, the maximum N contains 2 16 = 65536 values in the range from 0 to 65535.
Если Y0=01.01.1900, то получаемIf Y0 = 01/01/1900, then we obtain
- при N=0 дату 01.01.1900,- when N = 0, the date is 01.01.1900,
- при N=1 - 02.01.1900,- at N = 1 - 02/01/1900,
- при N=31 - 01.02.1900,- at N = 31 - 02/01/1900,
- при N=372 - 01.01.1901 и т.д.- at N = 372 - 01/01/1901, etc.
Используя данный метод для первоначальной даты Y0=01.01.1900, получаем максимальную дату 02.03.2076. Если брать только полностью входящие годы - 31.12.2075. В результате, обеспечивается диапазон в 176 лет, что на 6 лет больше, чем у известного способа, принятого за прототип, при сравнимой скорости вычислений.Using this method for the initial date Y0 = 01/01/1900, we obtain the maximum date 03/02/2076. If you take only the completely incoming years - 12/31/2075. As a result, a range of 176 years is provided, which is 6 years more than the known method adopted as a prototype, with a comparable computational speed.
Для рассмотренного варианта, когда за первоначальную дату берется Y0=01.01.1900, максимальная дата по способу от Microsoft получается 06.06.2079 (покрывается диапазон в 65536 дней, обозначим как i), по способу прототипа - 30.08.2070 (62334 дня, обозначим как р), по предложенному способу - 02.03.2076 (64345 дня, обозначим как v). Таким образом, способ прототипа обеспечивает p/i=62334/65536≈95.11%, а предложенный способ v/i=64345/65536≈98,18%, от максимально возможного. При этом, если способ прототипа теряет около 5% значений от максимально возможного, то предложенный способ - только около 2%.For the considered option, when Y0 = 01/01/1900 is taken for the initial date, the maximum date by the method from Microsoft is 06.06.2079 (the range of 65536 days is covered, denoted by i), by the prototype method it is 30.08.2070 (62334 days, denoted by p), according to the proposed method - 03/02/2076 (64345 days, denote by v). Thus, the prototype method provides p / i = 62334 / 65536≈95.11%, and the proposed method v / i = 64345 / 65536≈98.18% of the maximum possible. Moreover, if the prototype method loses about 5% of the values of the maximum possible, then the proposed method is only about 2%.
Таким образом, предложенный способ позволяет увеличить диапазон значений даты при сравнимой простоте и скорости вычислений, а также компактности хранения данных.Thus, the proposed method allows to increase the range of date values with comparable simplicity and speed of calculations, as well as compact data storage.
Осуществление изобретенияThe implementation of the invention
Реализация предложенного способа может быть осуществлена в вычислительной системе, способной производить операции целочисленного деления, т.е. практически в любой, включая системы, работающие, например, под управлением операционной системы MS Windows.Implementation of the proposed method can be implemented in a computer system capable of performing integer division operations, i.e. in almost any, including systems running, for example, running the MS Windows operating system.
Для реализации способа достаточно реализовать выполнение предложенных операций на каком-либо языке программирования.To implement the method, it is sufficient to implement the implementation of the proposed operations in any programming language.
Например, на языке С# реализация может выглядеть следующим образом: For example, in C #, an implementation might look like this:
Реализовать действия предложенного способа в составе программы или функции может специалист в области программирования (программист). Наибольший эффект применение предложенного способа может дать в системах, обрабатывающих данные о датах и имеющих сильные ограничения на объем памяти и аппаратные ресурсы, а также передающие информацию о датах в условиях ограничения на объем передаваемой информации.Implement the actions of the proposed method as part of a program or function can be a specialist in programming (programmer). The application of the proposed method can have the greatest effect in systems that process date data and have strong restrictions on the amount of memory and hardware resources, as well as transmitting information about dates under conditions of restrictions on the amount of transmitted information.
Примерами таких систем могут служить системы, хранящие и/или передающие различную информацию, в том числе и даты (например, даты рождения человека, дата отправки груза, дата отправления поезда и т.п.) в виде штрих-кода. В этом случае каждый сэкономленный бит имеет значение.Examples of such systems are systems that store and / or transmit various information, including dates (for example, the date of birth of a person, the date of departure of the goods, the date of departure of the train, etc.) in the form of a bar code. In this case, each bit saved is significant.
Эффективно также применение способа в системах и базах данных, в которых имеется большой объем данных с датами, в этом случае может достигаться значительная экономия объема хранения.It is also effective to use the method in systems and databases in which there is a large amount of data with dates, in which case significant savings in storage volume can be achieved.
Источники информацииInformation sources
1. Дата и время (Transact-SQL), статья по адресу1. Date and time (Transact-SQL), article at
https://msdn.microsoft.com/ru-ru/library/ms 187819(%D 1%83=sq1.90).aspxhttps://msdn.microsoft.com/en-us/library/ms 187819 (% D 1% 83 = sq1.90) .aspx
2. Datetime (Transact-SQL), статья по адресу2. Datetime (Transact-SQL), article at
https://msdn.microsoft.com/ru-ru/library/ms 187819(%D 1%83=sq1. 110).aspxhttps://msdn.microsoft.com/en-us/library/ms 187819 (% D 1% 83 = sq1. 110) .aspx
3. Julian day, статья по адресу3. Julian day, article at
http://en.wikipedia.org/wiki/Julian_dayhttp://en.wikipedia.org/wiki/Julian_day
4. Патент РФ №2543961, приоритет от 16.01.2013 г.4. RF patent No. 2543961, priority dated January 16, 2013.
Claims (13)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| RU2016114982A RU2615336C1 (en) | 2016-04-19 | 2016-04-19 | Method for encoding and computing date using simplified format in digital devices |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| RU2016114982A RU2615336C1 (en) | 2016-04-19 | 2016-04-19 | Method for encoding and computing date using simplified format in digital devices |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| RU2615336C1 true RU2615336C1 (en) | 2017-04-04 |
Family
ID=58505801
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| RU2016114982A RU2615336C1 (en) | 2016-04-19 | 2016-04-19 | Method for encoding and computing date using simplified format in digital devices |
Country Status (1)
| Country | Link |
|---|---|
| RU (1) | RU2615336C1 (en) |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US5793716A (en) * | 1995-12-19 | 1998-08-11 | Platinum Technology, Inc. | Date conversions with a 360-day-year calendar |
| US6044219A (en) * | 1997-04-01 | 2000-03-28 | Platinum Technology, Inc. | Date logic generator |
| US20080301212A1 (en) * | 2007-06-01 | 2008-12-04 | International Business Machines Corporation | Real time universal date and time conversion |
| RU2543961C2 (en) * | 2013-01-16 | 2015-03-10 | Открытое Акционерное Общество "Информационные Технологии И Коммуникационные Системы" | Date encoding and computation method using simplified format in digital devices |
-
2016
- 2016-04-19 RU RU2016114982A patent/RU2615336C1/en active
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US5793716A (en) * | 1995-12-19 | 1998-08-11 | Platinum Technology, Inc. | Date conversions with a 360-day-year calendar |
| US6044219A (en) * | 1997-04-01 | 2000-03-28 | Platinum Technology, Inc. | Date logic generator |
| US20080301212A1 (en) * | 2007-06-01 | 2008-12-04 | International Business Machines Corporation | Real time universal date and time conversion |
| RU2543961C2 (en) * | 2013-01-16 | 2015-03-10 | Открытое Акционерное Общество "Информационные Технологии И Коммуникационные Системы" | Date encoding and computation method using simplified format in digital devices |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US8413169B2 (en) | Time-based event processing using punctuation events | |
| CN112199707B (en) | Data processing method, device and equipment in homomorphic encryption | |
| EP3555742B1 (en) | Floating point instruction format with embedded rounding rule | |
| CN110879854B (en) | Searching data using superset tree data structures | |
| US20190370065A1 (en) | Systems and Methods for Caching Task Execution | |
| US20160291880A1 (en) | Reference counting for memory areas | |
| RU2701716C2 (en) | Electronic computer for performing arithmetic with obfuscation | |
| CN117435855B (en) | Method for performing convolution operation, electronic device, and storage medium | |
| WO2017097159A1 (en) | Method and apparatus for generating random character string | |
| Roos | An improved version of Chubanov's method for solving a homogeneous feasibility problem | |
| RU2543961C2 (en) | Date encoding and computation method using simplified format in digital devices | |
| Gürsoy et al. | Some Convergence and Stability Results for the Kirk Multistep and Kirk‐SP Fixed Point Iterative Algorithms | |
| RU2615336C1 (en) | Method for encoding and computing date using simplified format in digital devices | |
| CN110874346B (en) | Compression scheme for floating point values | |
| RU2639669C1 (en) | Method encoding and computing date using simplified format in digital devices | |
| CN107451070B (en) | Data processing method and server | |
| RU2630421C1 (en) | Method of coding and calculation of date with use of simplified format in digital devices | |
| CN115543514A (en) | Pointer display method, device, chip, electronic watch and readable storage medium | |
| KR101666974B1 (en) | Prime number generation | |
| Ghosh et al. | Evaluating bernstein–rabin–winograd polynomials | |
| US8930431B2 (en) | Parallel computation of a remainder by division of a sequence of bytes | |
| Wang et al. | CreditRisk+ model with dependent risk factors | |
| US11281427B2 (en) | Fast sort engine | |
| US11917052B2 (en) | Hash algorithm method, hash algorithm circuit, and electronic device | |
| Banerjee et al. | Sums of two squares visualized |