query
On this page

toHexString

lib.trivial.toHexString

Docs pulled from | This Revision | about 2 hours ago


Convert the given positive integer to a string of its hexadecimal representation. For example:

toHexString 0 => "0"

toHexString 16 => "10"

toHexString 250 => "FA"


Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

toHexString = let
    hexDigits = {
      "10" = "A";
      "11" = "B";
      "12" = "C";
      "13" = "D";
      "14" = "E";
      "15" = "F";
    };
    toHexDigit = d:
      if d < 10
      then toString d
      else hexDigits.${toString d};
  in i: lib.concatMapStrings toHexDigit (toBaseDigits 16 i);