-
Notifications
You must be signed in to change notification settings - Fork 0
ДЗ № 12.2 Double под микроскопом, Шестаков Николай #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
NicholayShestakov
wants to merge
7
commits into
main
Choose a base branch
from
double_under_microscope
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2f7a6d3
Add .clang-format
NicholayShestakov ef62ccc
Add build-and-lint.yml
NicholayShestakov 55d7b51
Add dependabot.yml
NicholayShestakov 6f45676
Rename job in build-and-lint.yml
NicholayShestakov bcd1281
Add double under microscope
NicholayShestakov 83174ad
Add CMakeLists.txt for build double under microscope
NicholayShestakov 78d73bc
Add build directory to gitignore
NicholayShestakov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,245 @@ | ||
| --- | ||
| Language: Cpp | ||
| # BasedOnStyle: WebKit | ||
| AccessModifierOffset: -4 | ||
| AlignAfterOpenBracket: DontAlign | ||
| AlignArrayOfStructures: None | ||
| AlignConsecutiveAssignments: | ||
| Enabled: false | ||
| AcrossEmptyLines: false | ||
| AcrossComments: false | ||
| AlignCompound: false | ||
| AlignFunctionPointers: false | ||
| PadOperators: true | ||
| AlignConsecutiveBitFields: | ||
| Enabled: false | ||
| AcrossEmptyLines: false | ||
| AcrossComments: false | ||
| AlignCompound: false | ||
| AlignFunctionPointers: false | ||
| PadOperators: false | ||
| AlignConsecutiveDeclarations: | ||
| Enabled: false | ||
| AcrossEmptyLines: false | ||
| AcrossComments: false | ||
| AlignCompound: false | ||
| AlignFunctionPointers: false | ||
| PadOperators: false | ||
| AlignConsecutiveMacros: | ||
| Enabled: false | ||
| AcrossEmptyLines: false | ||
| AcrossComments: false | ||
| AlignCompound: false | ||
| AlignFunctionPointers: false | ||
| PadOperators: false | ||
| AlignConsecutiveShortCaseStatements: | ||
| Enabled: false | ||
| AcrossEmptyLines: false | ||
| AcrossComments: false | ||
| AlignCaseColons: false | ||
| AlignEscapedNewlines: Right | ||
| AlignOperands: DontAlign | ||
| AlignTrailingComments: | ||
| Kind: Never | ||
| OverEmptyLines: 0 | ||
| AllowAllArgumentsOnNextLine: true | ||
| AllowAllParametersOfDeclarationOnNextLine: true | ||
| AllowBreakBeforeNoexceptSpecifier: Never | ||
| AllowShortBlocksOnASingleLine: Empty | ||
| AllowShortCaseLabelsOnASingleLine: false | ||
| AllowShortCompoundRequirementOnASingleLine: true | ||
| AllowShortEnumsOnASingleLine: true | ||
| AllowShortFunctionsOnASingleLine: All | ||
| AllowShortIfStatementsOnASingleLine: Never | ||
| AllowShortLambdasOnASingleLine: All | ||
| AllowShortLoopsOnASingleLine: false | ||
| AlwaysBreakAfterDefinitionReturnType: None | ||
| AlwaysBreakAfterReturnType: None | ||
| AlwaysBreakBeforeMultilineStrings: false | ||
| AlwaysBreakTemplateDeclarations: MultiLine | ||
| AttributeMacros: | ||
| - __capability | ||
| BinPackArguments: true | ||
| BinPackParameters: true | ||
| BitFieldColonSpacing: Both | ||
| BraceWrapping: | ||
| AfterCaseLabel: false | ||
| AfterClass: false | ||
| AfterControlStatement: Never | ||
| AfterEnum: false | ||
| AfterExternBlock: false | ||
| AfterFunction: true | ||
| AfterNamespace: false | ||
| AfterObjCDeclaration: false | ||
| AfterStruct: false | ||
| AfterUnion: false | ||
| BeforeCatch: false | ||
| BeforeElse: false | ||
| BeforeLambdaBody: false | ||
| BeforeWhile: false | ||
| IndentBraces: false | ||
| SplitEmptyFunction: true | ||
| SplitEmptyRecord: true | ||
| SplitEmptyNamespace: true | ||
| BreakAdjacentStringLiterals: true | ||
| BreakAfterAttributes: Leave | ||
| BreakAfterJavaFieldAnnotations: false | ||
| BreakArrays: true | ||
| BreakBeforeBinaryOperators: All | ||
| BreakBeforeConceptDeclarations: Always | ||
| BreakBeforeBraces: WebKit | ||
| BreakBeforeInlineASMColon: OnlyMultiline | ||
| BreakBeforeTernaryOperators: true | ||
| BreakConstructorInitializers: BeforeComma | ||
| BreakInheritanceList: BeforeColon | ||
| BreakStringLiterals: true | ||
| ColumnLimit: 0 | ||
| CommentPragmas: '^ IWYU pragma:' | ||
| CompactNamespaces: false | ||
| ConstructorInitializerIndentWidth: 4 | ||
| ContinuationIndentWidth: 4 | ||
| Cpp11BracedListStyle: false | ||
| DerivePointerAlignment: false | ||
| DisableFormat: false | ||
| EmptyLineAfterAccessModifier: Never | ||
| EmptyLineBeforeAccessModifier: LogicalBlock | ||
| ExperimentalAutoDetectBinPacking: false | ||
| FixNamespaceComments: false | ||
| ForEachMacros: | ||
| - foreach | ||
| - Q_FOREACH | ||
| - BOOST_FOREACH | ||
| IfMacros: | ||
| - KJ_IF_MAYBE | ||
| IncludeBlocks: Preserve | ||
| IncludeCategories: | ||
| - Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
| Priority: 2 | ||
| SortPriority: 0 | ||
| CaseSensitive: false | ||
| - Regex: '^(<|"(gtest|gmock|isl|json)/)' | ||
| Priority: 3 | ||
| SortPriority: 0 | ||
| CaseSensitive: false | ||
| - Regex: '.*' | ||
| Priority: 1 | ||
| SortPriority: 0 | ||
| CaseSensitive: false | ||
| IncludeIsMainRegex: '(Test)?$' | ||
| IncludeIsMainSourceRegex: '' | ||
| IndentAccessModifiers: false | ||
| IndentCaseBlocks: false | ||
| IndentCaseLabels: false | ||
| IndentExternBlock: AfterExternBlock | ||
| IndentGotoLabels: true | ||
| IndentPPDirectives: None | ||
| IndentRequiresClause: true | ||
| IndentWidth: 4 | ||
| IndentWrappedFunctionNames: false | ||
| InsertBraces: false | ||
| InsertNewlineAtEOF: false | ||
| InsertTrailingCommas: None | ||
| IntegerLiteralSeparator: | ||
| Binary: 0 | ||
| BinaryMinDigits: 0 | ||
| Decimal: 0 | ||
| DecimalMinDigits: 0 | ||
| Hex: 0 | ||
| HexMinDigits: 0 | ||
| JavaScriptQuotes: Leave | ||
| JavaScriptWrapImports: true | ||
| KeepEmptyLinesAtTheStartOfBlocks: true | ||
| KeepEmptyLinesAtEOF: false | ||
| LambdaBodyIndentation: Signature | ||
| LineEnding: DeriveLF | ||
| MacroBlockBegin: '' | ||
| MacroBlockEnd: '' | ||
| MaxEmptyLinesToKeep: 1 | ||
| NamespaceIndentation: Inner | ||
| ObjCBinPackProtocolList: Auto | ||
| ObjCBlockIndentWidth: 4 | ||
| ObjCBreakBeforeNestedBlockParam: true | ||
| ObjCSpaceAfterProperty: true | ||
| ObjCSpaceBeforeProtocolList: true | ||
| PackConstructorInitializers: BinPack | ||
| PenaltyBreakAssignment: 2 | ||
| PenaltyBreakBeforeFirstCallParameter: 19 | ||
| PenaltyBreakComment: 300 | ||
| PenaltyBreakFirstLessLess: 120 | ||
| PenaltyBreakOpenParenthesis: 0 | ||
| PenaltyBreakScopeResolution: 500 | ||
| PenaltyBreakString: 1000 | ||
| PenaltyBreakTemplateDeclaration: 10 | ||
| PenaltyExcessCharacter: 1000000 | ||
| PenaltyIndentedWhitespace: 0 | ||
| PenaltyReturnTypeOnItsOwnLine: 60 | ||
| PointerAlignment: Left | ||
| PPIndentWidth: -1 | ||
| QualifierAlignment: Leave | ||
| ReferenceAlignment: Pointer | ||
| ReflowComments: true | ||
| RemoveBracesLLVM: false | ||
| RemoveParentheses: Leave | ||
| RemoveSemicolon: false | ||
| RequiresClausePosition: OwnLine | ||
| RequiresExpressionIndentation: OuterScope | ||
| SeparateDefinitionBlocks: Leave | ||
| ShortNamespaceLines: 1 | ||
| SkipMacroDefinitionBody: false | ||
| SortIncludes: CaseSensitive | ||
| SortJavaStaticImport: Before | ||
| SortUsingDeclarations: LexicographicNumeric | ||
| SpaceAfterCStyleCast: false | ||
| SpaceAfterLogicalNot: false | ||
| SpaceAfterTemplateKeyword: true | ||
| SpaceAroundPointerQualifiers: Default | ||
| SpaceBeforeAssignmentOperators: true | ||
| SpaceBeforeCaseColon: false | ||
| SpaceBeforeCpp11BracedList: true | ||
| SpaceBeforeCtorInitializerColon: true | ||
| SpaceBeforeInheritanceColon: true | ||
| SpaceBeforeJsonColon: false | ||
| SpaceBeforeParens: ControlStatements | ||
| SpaceBeforeParensOptions: | ||
| AfterControlStatements: true | ||
| AfterForeachMacros: true | ||
| AfterFunctionDefinitionName: false | ||
| AfterFunctionDeclarationName: false | ||
| AfterIfMacros: true | ||
| AfterOverloadedOperator: false | ||
| AfterPlacementOperator: true | ||
| AfterRequiresInClause: false | ||
| AfterRequiresInExpression: false | ||
| BeforeNonEmptyParentheses: false | ||
| SpaceBeforeRangeBasedForLoopColon: true | ||
| SpaceBeforeSquareBrackets: false | ||
| SpaceInEmptyBlock: true | ||
| SpacesBeforeTrailingComments: 1 | ||
| SpacesInAngles: Never | ||
| SpacesInContainerLiterals: true | ||
| SpacesInLineCommentPrefix: | ||
| Minimum: 1 | ||
| Maximum: -1 | ||
| SpacesInParens: Never | ||
| SpacesInParensOptions: | ||
| InCStyleCasts: false | ||
| InConditionalStatements: false | ||
| InEmptyParentheses: false | ||
| Other: false | ||
| SpacesInSquareBrackets: false | ||
| Standard: Latest | ||
| StatementAttributeLikeMacros: | ||
| - Q_EMIT | ||
| StatementMacros: | ||
| - Q_UNUSED | ||
| - QT_REQUIRE_VERSION | ||
| TabWidth: 8 | ||
| UseTab: Never | ||
| VerilogBreakBetweenInstancePorts: true | ||
| WhitespaceSensitiveMacros: | ||
| - BOOST_PP_STRINGIZE | ||
| - CF_SWIFT_NAME | ||
| - NS_SWIFT_NAME | ||
| - PP_STRINGIZE | ||
| - STRINGIZE | ||
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: github-actions | ||
| directory: / | ||
| schedule: | ||
| interval: "weekly" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| name: Build and lint | ||
|
|
||
| on: | ||
| - push | ||
| - pull_request | ||
|
|
||
| jobs: | ||
| check-format: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - name: Check format | ||
| run: | | ||
| find . -path ./build -prune -o -type f -name '*.[c|h]' -print | xargs clang-format-18 --style=file --dry-run -Werror |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,4 +55,7 @@ Module.symvers | |
| Mkfile.old | ||
| dkms.conf | ||
|
|
||
| # CMake | ||
| build | ||
|
|
||
| # End of https://www.toptal.com/developers/gitignore/api/c | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| cmake_minimum_required(VERSION 3.25) | ||
| project(double_under_microscope C) | ||
|
|
||
| add_executable(double_under_microscope src/double_under_microscope/double_under_microscope.c) | ||
| target_compile_options(double_under_microscope PRIVATE -Wall -Wextra -pedantic) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||
| #include <stdio.h> | ||||||
|
|
||||||
| typedef struct BitField { | ||||||
| unsigned long mantissa : 52; | ||||||
| unsigned int exp : 11; | ||||||
| unsigned int sign : 1; | ||||||
| } BitField; | ||||||
|
|
||||||
| typedef union Number { | ||||||
| double number; | ||||||
| BitField bitField; | ||||||
| } Number; | ||||||
|
|
||||||
| int main() | ||||||
| { | ||||||
| Number number; | ||||||
| printf("Enter a number: "); | ||||||
| scanf("%lf", &number.number); | ||||||
|
|
||||||
| char sign = number.bitField.sign ? '-' : '+'; | ||||||
| // Считаем экспоненту. | ||||||
| int exponent = number.bitField.exp - 1023; | ||||||
| // Считаем мантиссу. | ||||||
| double mantissa = number.bitField.mantissa; | ||||||
| unsigned long two_in_52_pow = 1; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| two_in_52_pow = two_in_52_pow << 52; | ||||||
| double mantissaNormalized = 1 + mantissa / two_in_52_pow; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Хмм, такого я ещё не видел, но, наверное, оно работает. |
||||||
|
|
||||||
| printf("Result: %c%.52f*2^%d\n", sign, mantissaNormalized, exponent); | ||||||
|
|
||||||
| return 0; | ||||||
| } | ||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.