Show
Ignore:
Timestamp:
11/30/07 17:00:59 (9 months ago)
Author:
joshr
Message:

tabs replaced with spaces. We use ts=4 sw=4 in vi.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Swishetest/trunk/NotRand.pm

    r1959 r1965  
    1414use vars qw( $last ); 
    1515sub not_rand { 
    16        my $max = $_[0] || 1;   # if no value is passed, we return '0' or '1' 
    17        use integer;    # is it faster not to use integer? No, it's faster to USE int. 
    18        $last = 1 unless defined($last); 
    19         $last = ($last*21+1);    
    20                # from "Advanced Perl Programming", 4.4 Using Closures.  
    21                # We truncate to 30 bits to preclude system overflow and thereby be more portable 
    22                # that would be 'mod 2 ** 30' (1,073,741,824), which makes sense, 4.2G over 4 
    23        $last %= 1_073_741_824; # that's 2 to the 30th 
    24        #print "rand of $max is " . abs($last % $max) . "\n"; 
    25        return abs($last % $max);       # abs isn't needed 
     16    my $max = $_[0] || 1;   # if no value is passed, we return '0' or '1' 
     17    use integer;    # is it faster not to use integer? No, it's faster to USE int. 
     18    $last = 1 unless defined($last); 
     19    $last = ($last*21+1);    
     20        # from "Advanced Perl Programming", 4.4 Using Closures.  
     21        # We truncate to 30 bits to preclude system overflow and thereby be more portable 
     22        # that would be 'mod 2 ** 30' (1,073,741,824), which makes sense, 4.2G over 4 
     23    $last %= 1_073_741_824; # that's 2 to the 30th 
     24    #print "rand of $max is " . abs($last % $max) . "\n"; 
     25    return abs($last % $max);   # abs isn't needed 
    2626} 
    2727