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

Method pad_decimals

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

Source from the content-addressed store, hash-verified

4978}
4979
4980String String::pad_decimals(int p_digits) const
4981{
4982 String s = *this;
4983 int c = s.find(".");
4984
4985 if (c == -1)
4986 {
4987 if (p_digits <= 0)
4988 {
4989 return s;
4990 }
4991 s += ".";
4992 c = s.length() - 1;
4993 }
4994 else
4995 {
4996 if (p_digits <= 0)
4997 {
4998 return s.substr(0, c);
4999 }
5000 }
5001
5002 if (s.length() - (c + 1) > p_digits)
5003 {
5004 s = s.substr(0, c + p_digits + 1);
5005 }
5006 else
5007 {
5008 while (s.length() - (c + 1) < p_digits)
5009 {
5010 s += "0";
5011 }
5012 }
5013 return s;
5014}
5015
5016String String::pad_zeros(int p_digits) const
5017{

Callers 1

humanize_sizeMethod · 0.80

Calls 3

findMethod · 0.45
lengthMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected