Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. vector<char> &int128_str(int128_t x) {
  2. vector<char> s;
  3. int tail = 0;
  4. int count = 0;
  5. bool read = true;
  6.  
  7. __int128_t temp
  8. __int128_t test = 1;
  9.  
  10. if (x < ((__int128_t)0))
  11. s.push_back('-'), x = - x;
  12. if (x == ((__int128_t)0)) {
  13. s.push_back('0');
  14. return s;
  15. }
  16.  
  17. while((test <= x) && (read)) {
  18. test = test + test; if (test < ((s128_o) 0)) { read = false; } t = test;
  19. test = test + test; if (test < ((s128_o) 0)) { read = false; }
  20. test = test + test; if (test < ((s128_o) 0)) { read = false; }
  21. test = test + t; if (test < ((s128_o) 0)) { read = false; }
  22. count ++;
  23. }
  24. while(count-- > 0) {
  25. test = tail = 1;
  26. for(int i = 0; i < count; i++) {
  27. test = test + test; t = test;
  28. test = test + test;
  29. test = test + test;
  30. test = test + t;
  31. }
  32. while(x >= test)
  33. x = x - test, tail++;
  34. s.push_back('0' + tail);
  35. }
  36. return s;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement