Skip to content

Double под микроскопом#19

Open
EStarikov wants to merge 5 commits intomainfrom
double
Open

Double под микроскопом#19
EStarikov wants to merge 5 commits intomainfrom
double

Conversation

@EStarikov
Copy link
Owner

No description provided.

src/double.c Outdated
}
}

__uint64_t From2To10(int* arr, int l)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В C и C++ есть правило: нельзя использовать ничего, что начинается с одного подчёркивания и заглавной буквы, либо содержит где угодно в имени два подчёркивания подряд. В том числе, нельзя такие идентификаторы объявлять.
Правило очень строгое: за его несоблюдение сразу казнят (естественно, через UB).

Здесь надо использовать тип из stdint.h

src/double.c Outdated
int arr[8];
From10To2(arr, a->binaryForm[i]);
for (int j = 0; j <= 7; j++) {
array[56 - i * 8 + j] = arr[j];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Уберите все магические числа из программы.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что значит магические числа? Если вы про числа 56 и 8, то они возникают довольно естественно, и я не понимаю, как их можно убрать, завести под них константы?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Магические числа -- это термин такой. Антипаттерн, если хотите. И да, единственный способ от них избавиться -- это завести константы.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants