src/pyrepr/radix

Source   Edit  

Warning: currently any symbol besides hex , oct, bin, and their toLowerXxx is unstable

For toLowerXxx such as toLowerHex, they are just like Nim's strutils.toHex:

  • no prefix and sign char will be added
  • all x are treated as unsigned values (i.e., for signed integers, their two's complement representation will be used)

Procs

func addLower[baseBits: SBB](result: var string; x: BiggestUInt; len: Positive;
                             handleNegative: bool)
Source   Edit  
func addLower[baseBits: SBB](result: var string; x: SomeInt8)
Source   Edit  
func addLower[baseBits: SBB](result: var string; x: SomeInteger;
                             len: Positive = strLenInHex(typeof(x)))
Source   Edit  
func addLowerHex(result: var string; x: SomeInt8)
Source   Edit  
func addLowerHex[T: SomeInteger](result: var string; x: T;
                                 len: Positive = strLenInHex(T))

Converts x to its lower hexadecimal representation and add to result.

The resulting string will be exactly len characters long. No prefix like 0x is generated. x is treated as an unsigned value.

Source   Edit  
func bin[T: SomeInteger](x: T): string
Source   Edit  
func hex[T: SomeInteger](x: T): string
Source   Edit  
func oct[T: SomeInteger](x: T): string
Source   Edit  
func toLowerbin[T: SomeInteger](x: T; len: Positive = sizeof(T) * 8): string
Source   Edit  
func toLowerhex[T: SomeInteger](x: T; len: Positive = sizeof(T) * 2): string
Source   Edit  
func toLowerHex(s: openArray[char]): string {....raises: [], tags: [], forbids: [].}
Source   Edit  
func toLowerHex(s: openArray[char]; sep: char): string {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
func toLoweroct[T: SomeInteger](x: T; len: Positive = sizeof(T) * 3): string
Source   Edit