Roberto Ierusalimschy
0acd55898d
Added gcc option '-Wconversion'
...
No warnings for standard numerical types. Still pending alternative
numerical types.
2024-07-27 13:32:59 -03:00
Roberto Ierusalimschy
a08d82eb13
llimits.h being used by all Lua code
...
The definitions in llimits.h are useful not only for the core. That
header only defines types and '#define's, so libs and core still do
not share any real code/data.
2024-06-20 14:46:06 -03:00
Roberto Ierusalimschy
7237eb3f1c
Fixed warnings from different compilers
2024-02-15 11:18:34 -03:00
Roberto Ierusalimschy
9e99f3071d
Merge branch 'master' into nextversion
2023-11-07 17:25:46 -03:00
Roberto Ierusalimschy
edd8589f47
Avoid casts from unsigned long to floating-point
...
Old Microsoft compilers do not support those casts.
2023-09-08 11:34:39 -03:00
Roberto Ierusalimschy
86e8039a72
Clock component removed from 'luaL_makeseed'
...
'clock' can be quite slow on some machines.
2023-03-23 16:01:16 -03:00
Roberto Ierusalimschy
5a04f1851e
New function 'luaL_makeseed'
...
This function unifies code from 'lua_newstate', 'math.randomseed',
and 'table.sort' that tries to create a value with a minimum level
of randomness.
2023-03-20 16:13:17 -03:00
Roberto Ierusalimschy
82fae58e25
Details
...
Parentheses and comments.
2022-12-02 11:33:09 -03:00
Roberto Ierusalimschy
8dd2c912d2
Detail
...
Warnings with clang when using long double for Lua floats.
2022-01-03 09:12:17 -03:00
Roberto Ierusalimschy
59c88f846d
Broadening the use of branch hints
...
More uses of macros 'likely'/'unlikely' (renamed to
'l_likely'/'l_unlikely'), both in range (extended to the
libraries) and in scope (extended to hooks, stack growth).
2021-02-24 11:14:44 -03:00
Roberto Ierusalimschy
0ddc0f47bd
Several details about 5.4.0 rc1
...
Corrected several small details: added 'const', adjusts in tabs x
spaces, removed unused #includes and #defines, misspellings, etc.
2020-04-23 14:48:15 -03:00
Roberto Ierusalimschy
6eb53b7526
Details
...
Several details in code (e.g., moving a variable to the most inner
scope that encloses its uses), comments, parameter names, extra tests.
2020-02-27 12:59:22 -03:00
Roberto Ierusalimschy
2d92102dee
'l_mathlim' renamed to 'l_floatatt'
...
That macro is applied to float attributes, not to limits.
2019-12-05 13:31:07 -03:00
Roberto Ierusalimschy
b96b0b5abb
Added macro 'luaL_pushfail'
...
The macro 'luaL_pushfail' documents all places in the standard libraries
that return nil to signal some kind of failure. It is defined as
'lua_pushnil'. The manual also got a notation (@fail) to document those
returns. The tests were changed to be agnostic regarding whether 'fail'
is 'nil' or 'false'.
2019-08-16 14:58:02 -03:00
Roberto Ierusalimschy
2f22c6bb79
'math.randomseed' always returns the two seed components
2019-07-19 13:31:53 -03:00
Roberto Ierusalimschy
4eefef07ab
'math.randomseed()' returns the seeds it used
...
A call to 'math.randomseed()' returns the two components of the seed
it set, so that they can be used to set that same seed again.
2019-07-17 16:00:24 -03:00
Roberto Ierusalimschy
347d6961ac
Define LUA_MAXUNSIGNED as a preprocessor constant
...
The previous definition of LUA_MAXUNSIGNED used a typecast,
making it unsuitable for constant expressions in the preprocessor.
2019-05-14 11:10:24 -03:00
Roberto Ierusalimschy
279c3a6961
A few changes in tests about number of bits in integers
...
- The preprocessor must work with at least 'long', and therefore must
do shifts of up to 31 bits correctly.
- Whenever possible, use unsigned types in shifts.
2019-05-13 16:17:21 -03:00
Roberto Ierusalimschy
9eca305e75
'math.randomseed()' sets a somewhat random seed
...
When called with no arguments, 'math.randomseed' uses time and ASLR
to generate a somewhat random seed. the initial seed when Lua starts
is generated this way.
2019-03-13 14:47:48 -03:00
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