lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

To be able to print(a-64-bit-integer), I made the following changes to
lua_conf.h. Simple tests, e.g.,                                                           
                                                                                          
        > a = 2305843009213693955                                                         
        > print(a)                                                                        
        2305843009213693955                                                               
        > print(string.format("%x", 2305843009213693955))                                 
        2000000000000003                                                                  
                                                                                          
seem to work. My platform is 64-bit MIPS and I don't need floating point. I'm             
looking for some suggestions, e.g., on where things might go wrong with these 
changes.                                                                                  

Thanks.                                                                                   
Wei                                                                                       
                                                                                          

1. LUA_NUMBER 
        #if 0 /* wshi */
        #define LUA_NUMBER      double                                                    
        #else
        #define LUA_NUMBER      unsigned long long                                        
        #endif                                                                            

2. LUAI_UACNUMBER
        #if 0 /* wshi */
        #define LUAI_UACNUMBER  double                                                    
        #else
        #define LUAI_UACNUMBER  unsigned long long                                        
        #endif                                                                            

3. LUA_NUMBERSCAN and LUA_NUMBER_FMT                                                      
        #if 0 /* wshi */
        #define LUA_NUMBER_SCAN         "%lf"
        #define LUA_NUMBER_FMT          "%.14g"                                           
        #else
        #define LUA_NUMBER_SCAN         "%llu"                                            
        #define LUA_NUMBER_FMT          "%llu"                                            
        #endif                                                                            

4. LUA_USELONGLONG
        #define LUA_USELONGLONG /* wshi */                                                
        #if defined(LUA_USELONGLONG)                                                      
        
        #define LUA_INTFRMLEN           "ll" 
        #define LUA_INTFRM_T            long long                                         
        
        #else
        
        #define LUA_INTFRMLEN           "l"
        #define LUA_INTFRM_T            long

        #endif

5. lua_str2number
        #if 0 /* wshi */
        #define lua_str2number(s,p)     strtod((s), (p))
        #else
        #define lua_str2number(s,p)     strtoll((s), (p), 10)
        #endif