Skip to content

Add Bitwise Operations Support #1

@johndoe75

Description

@johndoe75

Add support for bitwise operations directly in the command syntax, allowing users to perform AND, OR, XOR, and bit shift operations alongside the existing number base conversion functionality.

While nmx excels at number base conversion, developers frequently need to perform bitwise operations on numbers. Currently, users would need to:

  • Convert numbers manually
  • Use separate tools or calculators for bitwise operations
  • Convert results back to desired format

This feature would make nmx a complete toolkit for number manipulation tasks commonly needed in systems programming, embedded development, and debugging.

Proposed Syntax

nmx "0x1f & 40"      # Bitwise AND
nmx "0x1f | 40"      # Bitwise OR  
nmx "0x1f ^ 40"      # Bitwise XOR
nmx "42 << 2"        # Left shift
nmx "42 >> 2"        # Right shift
nmx "~42"            # Bitwise NOT (unary)

Note: Quotes are required to prevent shell interpretation of special characters like & and |.

Expected Output

bash❯ nmx "0x1f & 40"
Expression: 0x1f & 40
Result: 8
Dec: 8
Hex: 0x8
Bin: 0b1000
❯ nmx "42 << 2"
Expression: 42 << 2
Result: 168
Dec: 168
Hex: 0xa8
Bin: 0b10101000

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions