Re: [Haskell-cafe] [Haskell] Silent error
 
            
            
            
            
                20 Jan
                
                    2013
                
            
            
                20 Jan
                
                '13
                
            
            
            
        
    
                6:27 p.m.
            
        On Mon, 21 Jan 2013, miphis@meta.ua wrote:
The program looks like this:
--*********************** factorial :: Int->Int factorial n = product [1..n]
main = do print $ factorial 50 --***********************
And that yields "0" (no errors). Is it a bug or feature? :)
This question is certainly better posted to haskell-cafe. The answer is: Int has limited bitsize (32 ord 64 bit depending on your machine), thus it computes factorial modulo 2^32 or 2^64. You can get the correct result by replacing Int by Integer.
        4667
        
      
          Age (days ago)
        
      
        4667
        
    
          Last active (days ago)
        
        
        
        0 comments
    
    
        
        1 participants
    
    
    
    
    
    
    
    
    participants (1)
- 
                 Henning Thielemann Henning Thielemann