Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: rigorously predictable random numbers



On Mon, May 20, 2024 at 12:14 PM Kannan Varadhan <kvaradhan3@xxxxxxxxx> wrote:
>
>> On 5/20/24 11:01, Roman Perepelitsa wrote:
>
>>> what does referring to them as '#b1', #b2', ... mean.
>
>> These are the numeric values of the bytes held in b1..b4.
>>
>>     % x='A'
>>     % print -r -- $(( #x ))
>>     65
>
> Interesting

This is documented in the "Arithmetic Evaluation" section of the
manual, about 3/4 of the way through:

An expression of the form '##X' where X is any character sequence such
as 'a', '^A', or '\M-\C-x' gives the value of this character and an
expression of the form '#NAME' gives the value of the first character of
the contents of the parameter NAME.  Character values are according to
the character set used in the current locale; for multibyte character
handling the option MULTIBYTE must be set.  Note that this form is
different from '$#NAME', a standard parameter substitution which gives
the length of the parameter NAME.  '#\' is accepted instead of '##', but
its use is deprecated.




Messages sorted by: Reverse Date, Date, Thread, Author