Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.79 KB | None | 0 0
  1. char* Functions::GoldToGoldVirgula(uint32_t num)
  2. {
  3.     if (num >= 1000000000) //Maior que 1KKK
  4.     {
  5.         std::ostringstream oss;
  6.         oss << std::setfill('0') << std::setw(10) << num;
  7.         auto retorno = oss.str().insert(1, ".").insert(5, ".").insert(9, ".");
  8.         return Functions::stringFormat("%s", retorno);
  9.     }
  10.     else
  11.     {
  12.         if (num >= 100000000) //Maior que 100kk
  13.         {
  14.             std::ostringstream oss;
  15.             oss << std::setfill('0') << std::setw(9) << num;
  16.             auto retorno = oss.str().insert(3, ".").insert(7, ".");
  17.             return Functions::stringFormat("%s", retorno);
  18.         }
  19.         else if (num >= 10000000) //Maior que 10kk
  20.         {
  21.             std::ostringstream oss;
  22.             oss << std::setfill('0') << std::setw(8) << num;
  23.             auto retorno = oss.str().insert(2, ".").insert(6, ".");
  24.             return Functions::stringFormat("%s", retorno);
  25.         }
  26.         else if (num >= 1000000) //Maior que 1kk
  27.         {
  28.             std::ostringstream oss;
  29.             oss << std::setfill('0') << std::setw(7) << num;
  30.             auto retorno = oss.str().insert(1, ".").insert(5, ".");
  31.             return Functions::stringFormat("%s", retorno);
  32.         }
  33.         else if (num >= 100000) //Maior que 100k
  34.         {
  35.             std::ostringstream oss;
  36.             oss << std::setfill('0') << std::setw(6) << num;
  37.             auto retorno = oss.str().insert(3, ".");
  38.             return Functions::stringFormat("%s", retorno);
  39.         }
  40.         else if (num >= 10000) //Maior que 10k
  41.         {
  42.             std::ostringstream oss;
  43.             oss << std::setfill('0') << std::setw(5) << num;
  44.             auto retorno = oss.str().insert(2, ".");
  45.             return Functions::stringFormat("%s", retorno);
  46.         }
  47.         else if (num >= 1000) //Maior que 1k
  48.         {
  49.             std::ostringstream oss;
  50.             oss << std::setfill('0') << std::setw(4) << num;
  51.             auto retorno = oss.str().insert(1, ".");
  52.             return Functions::stringFormat("%s", retorno);
  53.            
  54.         }
  55.         else //menor que 1k
  56.         {
  57.             return Functions::stringFormat("%d", num);
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement