Thread: Long overdue response for potentially useful code

  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733

    Long overdue response for potentially useful code

    Sorry that this took so long, at the time I didn't ecpect anyone to have any issues with it so I just forgot about the thread (and also lost my motivation to program so showed up late), here's an example of how I used the macros on https://www.onlinegdb.com/online_c_compiler:
    Code:
     #include  #include   #ifndef INT_BASE10_DIG #define INT_BASE10_DIG(BITS) (((((BITS)%3)==0)?(BITS):((BITS)+(3-((BITS)%3))))/3) #define BASE10_INT_BIT(DIGS) ((DIGS)*3)+(CHAR_BIT-(((DIGS)*3)%CHAR_BIT)) #endif  int main() {     int i = 0, max = sizeof(long long int) * CHAR_BIT;     printf("BITS : DIGITS");     while ( i < max ) {         printf( "\n%04i : %i", i, INT_BASE10_DIG(i) );         ++i;     } 	return 0; }
    which gave me this result:
    Code:
     BITS : DIGITS                                                                                         0000 : 0                                                                                              0001 : 1                                                                                              0002 : 1                                                                                              0003 : 1                                                                                              0004 : 2                                                                                              0005 : 2                                                                                              0006 : 2                                                                                              0007 : 3                                                                                              0008 : 3                                                                                              0009 : 3                                                                                              0010 : 4                                                                                              0011 : 4                                                                                              0012 : 4                                                                                              0013 : 5                                                                                              0014 : 5                                                                                              0015 : 5                                                                                              0016 : 6                                                                                              0017 : 6                                                                                              0018 : 6                                                                                              0019 : 7                                                                                              0020 : 7                                                                                              0021 : 7                                                                                              0022 : 8                                                                                              0023 : 8                                                                                              0024 : 8                                                                                              0025 : 9                                                                                              0026 : 9                                                                                              0027 : 9                                                                                              0028 : 10                                                                                             0029 : 10                                                                                             0030 : 10                                                                                             0031 : 11                                                                                             0032 : 11                         0033 : 11                                                                                             0034 : 12                                                                                             0035 : 12                                                                                             0036 : 12                                                                                             0037 : 13                                                                                             0038 : 13                                                                                             0039 : 13                                                                                             0040 : 14                                                                                             0041 : 14                                                                                             0042 : 14                                                                                             0043 : 15                                                                                             0044 : 15                                                                                             0045 : 15                                                                                             0046 : 16                                                                                             0047 : 16                                                                                             0048 : 16                                                                                             0049 : 17                                                                                             0050 : 17                                                                                             0051 : 17                                                                                             0052 : 18                                                                                             0053 : 18                                                                                             0054 : 18                                                                                             0055 : 19                                                                                             0056 : 19                                                                                             0057 : 19                                                                                             0058 : 20                                                                                             0059 : 20                                                                                             0060 : 20                                                                                             0061 : 21                                                                                             0062 : 21                                                                                             0063 : 21                                                                                                                                                                                                   ...Program finished with exit code 0                                                                  Press ENTER to exit console.
    Looking at it now I must've forgot something when translating what I did in the calculator to the macro but if one just adds forces an additional character then they can just sidestep the issue until either I or someone figures out what that forgotten bit is. Since there should be no need for replies on this admin please mark thread this as closed by the end of the week, if I figure out the fix I'll add it to here before then.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    any code which starts with "#include #include" is likely code I will ignore.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Potentially useful code
    By awsdert in forum C Programming
    Replies: 2
    Last Post: 07-03-2017, 09:13 AM
  2. Replies: 16
    Last Post: 06-07-2015, 03:28 PM
  3. Replies: 1
    Last Post: 10-11-2010, 01:53 AM
  4. Battlefield 1942 Closed Beta - Response Code
    By GaPe in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 09-29-2002, 07:20 AM

Tags for this Thread