Commit Graph

137 Commits

Author SHA1 Message Date
Roberto Ierusalimschy 51316f9df7 'math.rand()' uses higher bits to produce float value
The call 'math.rand()' converts the higher bits of the internal unsigned
integer random to a float, instead of its lower bits. That ensures that
Lua compiled with different float precisions always generates equal (up
to the available precision) random numbers when given the same seed.
2018-12-11 11:34:47 -02:00
Roberto Ierusalimschy f99509581e Removed extra information from RCS keyword strings
Version numbers and dates (mostly wrong) from RCS keyword strings
removed from all source files; only the file name are kept.
2018-08-23 14:26:12 -03:00
Roberto Ierusalimschy aedcfb9414 type 'Rand64' may not be long long, so it should not use 'LL' in its
constants
2018-06-14 15:47:22 -03:00
Roberto Ierusalimschy de53c2ec7e using some weak "randomness" (time and memory address) to initialize
seeds for the PRNG
2018-05-16 08:27:59 -03:00
Roberto Ierusalimschy 80bd4a8940 correction on xoshiro256** algorithm
(should use state[1] instead of state[0] for output)
2018-05-09 11:54:37 -03:00
Roberto Ierusalimschy 3e7415e846 reorganization of '#if's for sellecting a type for 'Rand64' +
comments
2018-05-04 17:01:45 -03:00
Roberto Ierusalimschy 762baf0548 detail (trim constants are unsigned) 2018-04-06 14:52:42 -03:00
Roberto Ierusalimschy b8a04658b2 PRNG changed from 'xoroshiro128+' to 'xoshiro256**' + "I' renamed 'Rand64'
+ implementation can use integer types larger than 64 (or 32) bits
2018-04-06 12:41:29 -03:00
Roberto Ierusalimschy b44787652b using 'xoroshiro128+' for PRNG
(plus a rotate at the final result to have better lower bits)
2018-04-04 13:12:53 -03:00
Roberto Ierusalimschy bdd10a08b1 in 'random', uses high-order bits instead of low-order
(better statistical properties)
2018-03-26 16:48:46 -03:00
Roberto Ierusalimschy c5e3b2f814 in random/'project', remove the special case for "small" intervals;
it is slower than the general case.
2018-03-22 16:54:49 -03:00
Roberto Ierusalimschy 89da4168df avoid functions named 'pack'
(name too common, may collide when doing 'onelua.c')
2018-03-16 11:18:18 -03:00
Roberto Ierusalimschy 6b01b6cf6a 'lu_int32' may not be 'int' 2018-03-12 09:39:03 -03:00
Roberto Ierusalimschy e3388ebfad more explicit casts when converting an integer to a random float
(to ensure computations are done with all bits)
2018-03-11 11:48:09 -03:00
Roberto Ierusalimschy dbec41f34c random floats of different sizes get exactly needed number of random bits
(up to 64)
2018-03-09 16:23:39 -03:00
Roberto Ierusalimschy 0b3db69e41 slight simplification in 'xorshift128plus' 2018-03-09 12:05:13 -03:00
Roberto Ierusalimschy 80ae1c1c16 fairer projection of random integers into an integer interval 2018-03-09 11:56:25 -03:00
Roberto Ierusalimschy 66b7b075a6 'math.random' using the xorshift128+ algorithm 2018-03-05 11:07:48 -03:00
Roberto Ierusalimschy 2a235312f0 detail (removing spaces at end of lines) 2016-12-22 11:08:50 -02:00
Roberto Ierusalimschy 9903dd52a3 Using LUAI_UAC* types more consistently on vararg calls 2016-12-20 16:37:00 -02:00
Roberto Ierusalimschy dc4232379d detail (ensure subtraction is done unsigned) 2015-10-02 12:39:23 -03:00
Roberto Ierusalimschy be63d995c1 tiny bug: 'randomseed' was calling 'rand' (instead of 'l_rand')
to discard first value
2015-06-26 16:30:32 -03:00
Roberto Ierusalimschy 7d930ec694 use 'log2' when available 2015-03-12 11:04:04 -03:00
Roberto Ierusalimschy 1a7868c1d5 bug: 'random' limit is 2^31-1, not RAND_MAX 2014-12-27 18:32:26 -02:00
Roberto Ierusalimschy 17ca3b1763 cleaner test for overflow for range of 'math.random' 2014-11-07 09:31:58 -02:00
Roberto Ierusalimschy 28fdbcf393 added include for 'lprefix.h', for stuff that must be added before
any other header file
2014-11-02 17:19:04 -02:00
Roberto Ierusalimschy 463edee2fd 'lua_numtointeger' -> 'lua_numbertointeger' 2014-10-24 09:42:06 -02:00
Roberto Ierusalimschy 65ec3379b1 added some casts for the cases when lua_Number != double 2014-10-08 16:57:31 -03:00
Roberto Ierusalimschy 798660c9cd deprecated "cast macros" ('luaL_checkint', 'luaL_optint', etc.) 2014-10-01 08:54:56 -03:00
Roberto Ierusalimschy 925d1b59f9 new function 'math.ult' (unsigned less than) 2014-07-28 14:35:47 -03:00
Roberto Ierusalimschy 8bb272a3e3 new conversion float->integer: conversion is valid only when
float has an exact representation as an integer
2014-07-17 09:30:53 -03:00
Roberto Ierusalimschy f14662fca6 detail (added placeholders for non-function fields to preallocate
space for them)
2014-07-16 10:56:14 -03:00
Roberto Ierusalimschy b9dcf9974d detail (typos in comments) 2014-06-30 16:48:08 -03:00
Roberto Ierusalimschy a77d263e86 unsigned-manipulation functions (lua_puhsunsigned, lua_tounsigned, etc.)
deprecated
2014-06-26 15:38:28 -03:00
Roberto Ierusalimschy e3871abe95 'math.ifloor' is back 2014-06-18 09:35:53 -03:00
Roberto Ierusalimschy 355037528c 'math.mof' works with integers, too 2014-06-02 20:09:28 -03:00
Roberto Ierusalimschy 456806f25c no more 'math.ifloor' + new semantics for 'math.floor'/'math.ceil' 2014-05-26 14:13:52 -03:00
Roberto Ierusalimschy 8b66040e34 several functions deprecated (cosh, sinh, atanh, pow, frexp, ldexp) 2014-05-14 13:59:27 -03:00
Roberto Ierusalimschy 6d5324f92f 'math.fmod' handles integers as integers 2014-05-02 13:36:51 -03:00
Roberto Ierusalimschy cbe4998bc2 'math.random(n,m)' interval restricted in size, to avoid using conversion
between 'double' and 'unsigned' (which can be slow and unreliable)
2014-04-17 13:09:40 -03:00
Roberto Ierusalimschy 5336cc9d6a math.random: use 'random' when available + changes to work correctly
for any integer interval (up to [minint,maxint])
2014-04-10 14:53:33 -03:00
Roberto Ierusalimschy fdd137276b more precision for PI + no more RADIANS_PER_DEGREE +
'min/maxint' -> 'min/maxinteger'
2014-04-09 14:29:46 -03:00
Roberto Ierusalimschy 8b45d9806a new constants 'math.maxint'/'math.minint' 2014-04-03 11:18:19 -03:00
Roberto Ierusalimschy 607be77ec8 some details to avoid warnings 2014-04-01 11:39:55 -03:00
Roberto Ierusalimschy 66b7b9b582 math.abs, math.max, and math.min work for integers, too. 2014-03-31 16:00:52 -03:00
Roberto Ierusalimschy 4244da96bf 'debug.subtype' -> 'math.type' (to distinguish integers and floats) 2013-07-22 13:05:53 -03:00
Roberto Ierusalimschy fcf99bf788 'math.isfloat' replaced by 'debug.subtype' 2013-07-10 17:57:05 -03:00
Roberto Ierusalimschy cbe164191c new function 'ifloor' 2013-07-03 14:23:19 -03:00
Roberto Ierusalimschy 15fdbd26fe 'numbits' moved from 'math' to 'debug' library 2013-06-25 16:37:00 -03:00
Roberto Ierusalimschy 80cdf39d0e avoid using 'modf' in the implementation of 'math.modf', to avoid
problems with 'double*'. (When using 'float' as lua_Number,
'float*' is not compatible with 'double*'...)
2013-06-25 11:02:18 -03:00