mysql-random-data-generator icon indicating copy to clipboard operation
mysql-random-data-generator copied to clipboard

get_float function is buggy

Open xjjo opened this issue 3 years ago • 1 comments

function get_float(in_precision int, in_scale int) do not work properly when precision is 1 and scale is 0 i.e table data type decimal(1,0)

xjjo avatar Aug 19 '22 14:08 xjjo

That's right, it occasionally go out of range. It works when the random number is within range though... not efficient but works! Will try working on the function.

mysql> select @x:=rand(), @x, @x*pow(10,1), round(@x*pow(10,1),0); +--------------------+--------------------+-------------------+-----------------------+ | @x:=rand() | @x | @x*pow(10,1) | round(@x*pow(10,1),0) | +--------------------+--------------------+-------------------+-----------------------+ | 0.9737842026853787 | 0.9737842026853787 | 9.737842026853787 | 10 | +--------------------+--------------------+-------------------+-----------------------+ 1 row in set, 1 warning (0.00 sec)

kedarvj avatar Oct 06 '22 06:10 kedarvj