Skip to content

Commit

Permalink
Merge pull request #71 from demo-exe/cb_fix
Browse files Browse the repository at this point in the history
fix: renamed 'cb' to 'bits' to avoid collision
  • Loading branch information
alt-romes authored Jan 29, 2023
2 parents 1d6c996 + 8d9944c commit 9ede07a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ output/*
pcalc
.DS_Store
.gitignore
.vscode/*.json
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ All three number representations are available at the same time, you can insert

By default, 64 bits are used for arithmetic, however, when working with bits, quite often we want to work with less. With this calculator you can change the amount of bits used. the number displayed will be unsigned

To use 16 bits instead, type `16cb` (cb for "change bits")
To use 16 bits instead, type `16bit` (bits will also work)

To use 8 bits, type `8cb`
To use 8 bits, type `8bit`

To use 0 < n <= 64 bits, type `ncb`
To use 0 < n <= 64 bits, type `nbit`


### Customizing Interface
Expand Down Expand Up @@ -157,7 +157,7 @@ RL : RR ; 2's _ SE @
* RL : `a : b` bit-wise ROTATE-LEFT operation : rotate a left b number of times
* RR : `a ; b` bit-wise ROTATE-LEFT operation : rotate a right b number of times
* 2's: `_a` 2's complement operation : 2's complement of a (usually is the symmetric of a)
* SE : `@a` swap endianness : swap the byte order of a (uses the number of bits set by `cb` to determine the amount of bits swapped)
* SE : `@a` swap endianness : swap the byte order of a (uses the number of bits set by `bit` to determine the amount of bits swapped)


## Contributing
Expand Down
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ <h4>Hex + Binary + Decimal</h4>

<h4>Operand Size</h4>
<p>By default, 64 bits are used for arithmetic, however, when working with bits, quite often we want to work with less. With this calculator you can change the amount of bits used. <small class="comment">the number displayed will be unsigned</small></p>
<p>To use 16 bits instead, type <span class="inline-code">16cb</span> <small class="comment">(cb for "change bits")</small></p>
<p>To use 8 bits, type <span class="inline-code">8cb</span></p>
<p>To use 0 < <em>n </em><= 64 bits, type <span class="inline-code"><em>n</em>cb</span></p>
<p>To use 16 bits instead, type <span class="inline-code">16bit</span> <small class="comment">(bits will also work)</small></p>
<p>To use 8 bits, type <span class="inline-code">8bit</span></p>
<p>To use 0 < <em>n </em><= 64 bits, type <span class="inline-code"><em>n</em>bit</span></p>

<br>

Expand Down Expand Up @@ -225,7 +225,7 @@ <h4>Operations</h4>
<li>2's: <span class="inline-code">_a</span> &nbsp;&nbsp; <small class="comment">2's complement operation : 2's complement of <em>a</em> (usually is the symmetric of a)</small></li>
</ul>
<ul>
<li>SE&nbsp;: <span class="inline-code">@a</span> &nbsp;&nbsp; <small class="comment">swap endianness : swap the byte order of <em>a</em> (uses the number of bits set by <em>cb</em> to determine the amount of bits swapped)</small></li>
<li>SE&nbsp;: <span class="inline-code">@a</span> &nbsp;&nbsp; <small class="comment">swap endianness : swap the byte order of <em>a</em> (uses the number of bits set by <em>bit</em> to determine the amount of bits swapped)</small></li>
</ul>

<div style="text-align:center; margin-top: 5em;">
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static void process_input(operation** current_op, char* in) {
else if (!strcmp(in, "operation"))
operation_enabled = !operation_enabled;

else if (strstr(in, "cb") != NULL) {
else if (strstr(in, "bit") != NULL) {

// Command to change the number of bits

Expand Down
14 changes: 7 additions & 7 deletions tests/expressions.test
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@
1;2;3;4;5

@0x1122334455667788
56cb
56bit
@0x11223344556677
48cb
48bit
@0x112233445566
40cb
40bit
@0x1122334455
32cb
32bit
@0x11223344
24cb
24bit
@0x112233
16cb
16bit
@0x1122
@0x11223344
8cb
8bit
@0x11
exit

0 comments on commit 9ede07a

Please sign in to comment.