mod(x,y)
Description: the modulus of x with respect to y
mod(x,y) = x - y*floor(x/y)
mod(x,0) = .
Domain x: -8e+307 to 8e+307
Domain y: 0 to 8e+307
Range: 0 to 8e+307
However it is giving me negative values, i.e., it goes in the negative Range. And as far as I can see I am not doing anything out of the limits of its Domain:
Code:
. clear . . sca Seed = 2147483647 . . set obs 10000000 number of observations (_N) was 0, now 10,000,000 . . gen double x = _n*Seed^2 . . summ x Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- x | 10,000,000 2.31e+25 1.33e+25 4.61e+18 4.61e+25 . . replace x = mod(x, 1000000000) (10,000,000 real changes made) . . summ x Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- x | 10,000,000 5.86e+07 6.72e+08 -3.29e+09 4.29e+09
0 Response to The modulus -mod()- function is giving me negative values. Is this a bug?
Post a Comment