Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Irv Mullins <irv at ELLIJAY.COM> Feb 17, 2000
- 787 views
On Wed, 16 Feb 2000, Everett Williams wrote: <snip code> > -- final now equals 80 bytes or 640 bits > printf(file_number, > "%04x%04x%04x%04x%04x%04x%04x%04x%04x%04x", > {final[ 1],final[ 2],final[ 3],final[ 4],final[ 5], > final[ 6],final[ 7],final[ 8],final[ 9],final[10]}) > > printf(file_number, > "%04x%04x%04x%04x%04x%04x%04x%04x%04x%04x\n", > {final[11],final[12],final[13],final[14],final[15], > final[16],final[17],final[18],final[19],final[20]}) Just so that newcomers to Euphoria aren't put off by the seeming complexity of the above, they should be aware that the previous lines can be replaced with: printf(file_number, fmt, final) providing that fmt has been previously defined or built programmatically, i.e. sequence fmt fmt = "" for i = 1 to 20 do fmt &= "%04x" end for fmt &= '\n' Euphoria's printf() statement will use as many data items as needed to match the number of items in the format string, and ignore the rest (if any) Only when there are fewer data items than format items will there be an error. This is a nice feature that can sometimes save a lot of typing, with little or no impact on execution speed. Regards, Irv