MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / num_int64

Method num_int64

modules/gui/gui/src/backend/text_server/ustring.cpp:1843–1887  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1841}
1842
1843String String::num_int64(int64_t p_num, int base, bool capitalize_hex)
1844{
1845 bool sign = p_num < 0;
1846
1847 int64_t n = p_num;
1848
1849 int chars = 0;
1850 do
1851 {
1852 n /= base;
1853 chars++;
1854 } while (n);
1855
1856 if (sign)
1857 {
1858 chars++;
1859 }
1860 String s;
1861 s.resize(chars + 1);
1862 char32_t* c = s.ptrw();
1863 c[chars] = 0;
1864 n = p_num;
1865 do
1866 {
1867 int mod = ABS(n % base);
1868 if (mod >= 10)
1869 {
1870 char a = (capitalize_hex ? 'A' : 'a');
1871 c[--chars] = a + (mod - 10);
1872 }
1873 else
1874 {
1875 c[--chars] = '0' + mod;
1876 }
1877
1878 n /= base;
1879 } while (n);
1880
1881 if (sign)
1882 {
1883 c[0] = '-';
1884 }
1885
1886 return s;
1887}
1888
1889String String::num_uint64(uint64_t p_num, int base, bool capitalize_hex)
1890{

Callers

nothing calls this directly

Calls 2

resizeMethod · 0.45
ptrwMethod · 0.45

Tested by

no test coverage detected