Jun 17, 2012

10000 digits of Euler's Number (constant e)

Well, this is an another constant that is used in many different places....
Hmm, I don't really like it! Because I have no feeling about this constant.



2.
7182818284 5904523536 0287471352 6624977572 4709369995

9574966967 6277240766 3035354759 4571382178 5251664274
2746639193 2003059921 8174135966 2904357290 0334295260
5956307273 1008532378 0527510636 8648701695 3141865527
4845908244 9550453392 8649764277 4136641659 6463663250
8736091584 1343970999 8317035382 3380092116 8146554153
7493054202 2246170932 1230949167 7634993111 3070302925
6989342067 6439191366 5038487357 8846610775 7255763079
2189886735 3790419412 0433774064 9490707386 3079049248
9764370698 3629736686 2198429250 7677002141 5740650029
3826954406 8718779542 7096976624 7465243666 2951385720
1920830317 7269234097 7016567453 9225777914 7341603684

Digits of tau

The following address links to the complete list of 100000 digits of Tau~
http://tauday.com/tau-digits

Here's the digits before the Feynman Point (a series of 9s).


6.
2831853071 7958647692 5286766559 0057683943 3879875021
1641949889 1846156328 1257241799 7256069650 6842341359
6429617302 6564613294 1876892191 0116446345 0718816256
9622349005 6820540387 7042211119 2892458979 0986076392
8857621951 3318668922 5695129646 7573566330 5424038182
9129713384 6920697220 9086532964 2678721452 0498282547
4491740132 1263117634 9763041841 9256585081 8343072873
5785180720 0226610610 9764093304 2768293903 8830232188
6611454073 1519183906 1843722347 6386522358 6210237096
1489247599 2549913470 3771505449 7824558763 6602389825
9667346724 8813132861 7204278989 2790449474 3814043597
2188740554 1078434352 5863535047 6934963693 5338810264
0011362542 9052712165 5571542685 5155792183 4727435744
2936881802 4499068602 9309917074 2101584559 3785178470
8403991222 4258043921 7280688363 1962725954 9542619921
0374144226 9999999674



Damn! I really love Tau!

Jun 12, 2012

Some useful macros

#ifdef(_MSC_VER)    //Identify VC compiler
#ifdef(__GNUC__)    //Identify GCC
#ifdef(__OBJC__)    //Identify Objective-C language
#ifdef(__cplusplus) //Identify C++
#ifdef(_WIN32)      //Identify Targeting Windows 32-bits OS
#ifdef(_WIN64)      //Identify Targeting Windows 64-bits OS

PI and TAU


PI = 3.141592653589793238462643383279......
TAU = 2PI = 6.283185307179586476925286766558......

The origin of TAU
        http://tauday.com/

Interesting~

Operating System Bit Size Detection using C/C++

#ifdef __GNUC__
    #include "stdint.h"
    #if INTPTR_MAX == INT32_MAX
        #define __ENV32
        #define __SYS_BITS 32
    #elif INTPTR_MAX == INT64_MAX
        #define __ENV64
        #define __SYS_BITS 64
    #else
        #define __ENV_UNKNOWN
        #define __SYS_BITS 0
    #endif
#elif defined(_WIN32)
    #define __ENV32
    #define __SYS_BITS 32
#elif defined(_WIN64)
    #define __ENV64
    #define __SYS_BITS 64
#else
    #define __SYS_BITS (sizeof(void*)*8)
#endif

Endianness Detection in C/C++

#define IS_LITTLE_ENDIAN (*(short*)"\0\1">>8)
#define IS_BIG_ENDIAN (*(short*)"\1\0">>8)

Structure Initialization in GCC and VC

---------------------------------
structure initialization
---------------------------------
typedef struct __t_obj
{
    char a;
    int b;
    char* str;
}obj;

/*GCC allows the following initialization methods*/
obj temp1 = {'X', 123, "this is a string"}; 
//complete initialization
obj temp2 = {.a = 'X', .str = "this is a string"}; 
//partially initialization
obj temp3; temp3.a = 'X'; temp3.b = 123;


/*VC2010 allows the following initialization methods*/
obj temp1 = {'X', 123, "this is a string"}; 
//complete initialization
obj temp3; temp3.a = 'X'; temp3.b = 123;

Compiling a *.c source file using GCC v.s. MSC 2010(Microsoft Compiler)

-----------------------
inline functions
-----------------------
#ifdef _MSC_VER 
    #define INLINE __forceinline 
    /* use __forceinline (VC++ specific) */
#elif defined(__GNUC__)
   #define INLINE inline __attribute__((always_inline))
   /* use __attribute__((always_inline)) (GCC 4.3 latr) */
#else
   #define INLINE inline
   /*use standard inline*/
#endif

---------------------------------------
local variable declaration
---------------------------------------
/*GCC allows intermediately declaration*/
int function()
{
    int a = 3, b= 5, c;
    b++;
    a++;
    c = a * b;

    char buffer = (char)c + a + b; 
    //error C2143: syntax error : missing ';' before 'type'
    return buffer; 
    //error C2065: 'buffer' : undeclared identifier

}

/*In VC2010, all declaration must be put at the start of the function*/
int function()
{
    int a = 3, b= 5, c;
    char buffer;
    b++;
    a++;
    c = a * b;
  
    buffer = (char)c + a + b;
    return buffer;
}