| 444 | } |
| 445 | |
| 446 | DefineEngineFunction(mDecToBin, const char*, (S32 n), , "convert decimal to a binary") |
| 447 | { |
| 448 | String ret; |
| 449 | while (n > 0) { |
| 450 | int r = n % 2;//modulus aka remainder of 2. nets you a 0 or a 1 |
| 451 | n /= 2;//next power of 2 |
| 452 | ret = String::ToString("%i",r) + ret;//add to the front of the stack |
| 453 | } |
| 454 | return ret.c_str(); |
| 455 | } |
no test coverage detected