home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer 3.14 / 1998-05_Disc_3.14.bin / addons / p2edit / convert.zip / CONVERT.CPP next >
C/C++ Source or Header  |  1998-02-04  |  2KB  |  66 lines

  1. /*
  2.     A short program designed to convert an integer to it's ASCII values.
  3.     (i.e. 65793 would come to 1 1 1 which means there is one of each of
  4.     the following numbers in that value.)
  5.     65536
  6.     256
  7.     1
  8.  
  9.     Programming: Bryan Carver (CodeLord)
  10.  
  11.     This source is copyright (c) Perspective Video & Electronics,
  12.     http://www.pvid.com
  13.  
  14.     Permission granted to use, abuse, re-write, distribute, and delete
  15.     this code in any means you wish.
  16. */
  17. #include <stdio.h>
  18. #include <iostream.h> //cin
  19.  
  20. //#include <conio.h>
  21. //#include <stdlib.h>
  22. //#include <string.h>
  23.  
  24. main()
  25. {
  26.    int cred1, cred2, cred3, cred4;
  27.    unsigned long credits, tempnum;
  28.  
  29.    credits = 0;
  30.  
  31. //   cred4 = 16777215;
  32.    printf("Maximum supportable number of this program is 16,777,215\n");
  33.    printf("Please omit all comma's\n\n");
  34.    printf("Enter the value you wish to convert: ");
  35.       cin >> credits;
  36.  
  37.    cred3 = credits / 65536;
  38.    tempnum = cred3 * 65536;
  39.    credits = credits - tempnum;
  40.    cred2 = credits / 256;
  41.    tempnum = cred2 * 256;
  42.    credits = credits - tempnum;
  43.    cred1 = credits / 1;
  44.    tempnum = cred1 * 1;
  45.    credits = credits - tempnum;
  46.    if (cred3 >= 256){
  47.       printf("\n\nNumber too large to compute\nTry a smaller integer\n");
  48.       cred1 = 0;
  49.       cred2 = 0;
  50.       cred3 = 0;
  51.    }
  52.  
  53. /*
  54.    char credits;
  55.    cin >> credits;
  56.    printf("%d", credits);
  57. */
  58.    printf("\n\nConversion...\n");
  59.    printf("Ones        : %d\n", cred1);
  60.    printf("256's       : %d\n", cred2);
  61.    printf("65536's     : %d\n", cred3);
  62. //   printf("4294967296's: %d\n", cred4);
  63.  
  64. return(0);
  65. }
  66.