Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 77a2f328c75c
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a96ed51a6122
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Dec 22, 2020

  1. Added to_string_hex

    azonenberg committed Dec 22, 2020
    Copy the full SHA
    a96ed51 View commit details
Showing with 19 additions and 0 deletions.
  1. +18 −0 scopehal/scopehal.cpp
  2. +1 −0 scopehal/scopehal.h
18 changes: 18 additions & 0 deletions scopehal/scopehal.cpp
Original file line number Diff line number Diff line change
@@ -555,6 +555,24 @@ string to_string_sci(double d)
return tmp;
}

/**
@brief Like std::to_string, but output in hex
*/
string to_string_hex(uint64_t n, bool zeropad, int len)
{
char format[32];
if(zeropad)
snprintf(format, sizeof(format), "%%0%dlx", len);
else if(len > 0)
snprintf(format, sizeof(format), "%%%dlx", len);
else
snprintf(format, sizeof(format), "%%lx");

char tmp[32];
snprintf(tmp, sizeof(tmp), format, n);
return tmp;
}

/**
@brief Rounds a 64-bit integer up to the next power of 2
*/
1 change: 1 addition & 0 deletions scopehal/scopehal.h
Original file line number Diff line number Diff line change
@@ -105,6 +105,7 @@ std::string BaseName(const std::string& path);
std::string ReadFile(const std::string& path);

std::string to_string_sci(double d);
std::string to_string_hex(uint64_t n, bool zeropad = false, int len = 0);

void TransportStaticInit();
void DriverStaticInit();