Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simuDAtor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
simuDAtor
Commits
fdae3172
Commit
fdae3172
authored
8 months ago
by
Johannes Kung
Browse files
Options
Downloads
Patches
Plain Diff
Implemented more formats
parent
fa064bdf
No related branches found
No related tags found
No related merge requests found
Pipeline
#134598
failed
8 months ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/simudator/gui/formatting.py
+12
-4
12 additions, 4 deletions
src/simudator/gui/formatting.py
with
12 additions
and
4 deletions
src/simudator/gui/formatting.py
+
12
−
4
View file @
fdae3172
...
@@ -82,17 +82,17 @@ def format_to_str(format_info: FormatInfo, value: Any) -> str:
...
@@ -82,17 +82,17 @@ def format_to_str(format_info: FormatInfo, value: Any) -> str:
"""
"""
match
format_info
.
selected_format
:
match
format_info
.
selected_format
:
case
Format
.
Int
:
case
Format
.
Int
:
pass
return
str
(
value
)
case
Format
.
Str
:
case
Format
.
Str
:
pass
return
str
(
value
)
case
Format
.
Bin
:
case
Format
.
Bin
:
return
f
"
{
value
:
0
{
format_info
.
kwargs
[
'
bit_length
'
]
}
b
}
"
return
f
"
{
value
:
0
{
format_info
.
kwargs
[
'
bit_length
'
]
}
b
}
"
case
Format
.
Hex
:
case
Format
.
Hex
:
return
f
"
{
value
:
0
{
math
.
ceil
(
format_info
.
kwargs
[
'
bit_length
'
]
/
4
)
}
x
}
"
return
f
"
{
value
:
0
{
math
.
ceil
(
format_info
.
kwargs
[
'
bit_length
'
]
/
4
)
}
x
}
"
case
Format
.
Decimal
:
case
Format
.
Decimal
:
pass
return
str
(
value
)
case
Format
.
DecimalSigned
:
case
Format
.
DecimalSigned
:
pass
return
str
(
value
-
2
**
format_info
.
kwargs
[
'
bit_length
'
])
def
parse_str
(
format_info
:
FormatInfo
,
value
:
str
)
->
Any
:
def
parse_str
(
format_info
:
FormatInfo
,
value
:
str
)
->
Any
:
...
@@ -114,5 +114,13 @@ def parse_str(format_info: FormatInfo, value: str) -> Any:
...
@@ -114,5 +114,13 @@ def parse_str(format_info: FormatInfo, value: str) -> Any:
match
format_info
.
selected_format
:
match
format_info
.
selected_format
:
case
Format
.
Int
:
case
Format
.
Int
:
return
int
(
value
)
return
int
(
value
)
case
Format
.
Bin
:
return
int
(
value
,
base
=
2
)
case
Format
.
Hex
:
case
Format
.
Hex
:
return
int
(
value
,
base
=
16
)
return
int
(
value
,
base
=
16
)
case
Format
.
Decimal
:
return
int
(
value
)
case
Format
.
DecimalSigned
:
# Turn negative numbers into the correct unsigned value
# e.g. bit length 3: -1 (0b111 in 2's complement) => 7
return
int
(
value
)
%
2
**
format_info
.
kwargs
[
'
bit_length
'
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment