Sponsored Content
Top Forums Programming generating 16 digit random number in C Post 302344754 by Corona688 on Monday 17th of August 2009 01:09:18 PM
Old 08-17-2009
Quote:
Originally Posted by ajaysahoo
its generating 16 digit no, but could please tell me that how the nos can be generated in double format.
I should add that a floating point datatype is the wrong kind of variable to hold integer data. Even a very high precision floating point value does not have complete precision. a 64-bit 'long long' type seems better suited. Or better yet, include stdint.h and use int64_t. To convert from a string, see atoll.

/dev/random has the problem that sometimes it may block. When there's not enough entropy available the read() call will wait until there is. crypto-grade randomness may not be needed unless this really is for crypto.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

generating random numbers with hamming distance 4

Hi I want to genrate 10 random 32 bit binary numbers with hamming distance 4 and 8. 11010110010101010101010101010101 11010110010101010100010101010010 if we look carefully at these two binary numbers they differ at 4 places hence hamming distance 4. Now I want to genrate these numbers... (2 Replies)
Discussion started by: hack_tom
2 Replies

2. Shell Programming and Scripting

Generating random number within a specific range (0.5-1.5)

Hello, need a way to generate numbers within 0.5-1.5 range Has to be totally random: 0.6 1.1 0.8 1.5 0.6 and so on.... How to? (10 Replies)
Discussion started by: TehOne
10 Replies

3. Shell Programming and Scripting

Generating random numbers

Hi, I am having trouble with generating random numbers. can this be done with awk? So I have a file that looks like this: 23 30 24 40 26 34 So column1 is start and column2 is end. I want to generate 3 random #'s between start and stop: So the output will look like this: ... (9 Replies)
Discussion started by: phil_heath
9 Replies

4. Programming

C Help; generating a random number.

Im new to C, and Im having a hard time getting a random number. In bash, I would do something similar to the following to get a random number; #!/bin/bash seed1=$RANDOM seed2=$RANDOM seed3=$RANDOM SEED=`expr $seed1 * $seed2 / $seed3` echo ${SEED%.*} Now, in online examples... (4 Replies)
Discussion started by: trey85stang
4 Replies

5. Programming

Generating Random Number in Child Process using Fork

Hello All, I am stuck up in a program where the rand functions ends up giving all the same integers. Tried sleep, but the numbers turned out to be same... Can anyone help me out how to fix this issue ? I have called the srand once in the program, but I feel like when I call fork the child process... (5 Replies)
Discussion started by: manisum
5 Replies

6. Shell Programming and Scripting

Generate 16 digit positive random Numbers

Hi Unix Gurus, I have a requirement to generate positive random 16 and 13 digit numbers. Here is the script I have so far..... number=$RANDOM$RANDOM$RANDOM$RANDOM; let "number %= 10000000000000"; echo $number But sometimes it is generating negative numbers and also 15 digit... (8 Replies)
Discussion started by: scorpioraghu
8 Replies

7. Shell Programming and Scripting

Generating Random Number in certain range

Hi there I am trying to generate a random number between 40 and 70 using the shell here is my code so far and it keeps going above 70. all help much appreciated! comp=$(( RANDOM%70+40 )) echo $comp (4 Replies)
Discussion started by: faintingquiche
4 Replies

8. Shell Programming and Scripting

Random number generating script?

Having a hard time with this. Very new to scripting and linux. Spent all sunday trying to do this. Appreciate some help and maybe help breaking down what the syntax does. Create a Bash program. It should have the following properties • Creates a secret number between 1 and 100 i. The... (3 Replies)
Discussion started by: LINUXnoob15
3 Replies

9. Shell Programming and Scripting

Generating a Random String of 'n' length

Hi, How can I generate a string of random characters (alpha+numeric) of a particular length ? For e.g. for n=5, output = 'kasjf' n=10, output = 'hedbcd902k' Also, please let me know if random (valid) dates could also be generated. Thanks (7 Replies)
Discussion started by: rishigc
7 Replies

10. Shell Programming and Scripting

Generating a POSIX random number?

Hi Guys and gals... As you know I am getting to grips with POSIX and hit this stumbling block. Generating two random numbers 0 to 255 POSIXly. Speed in not important hence the 'sleep 1' command. I have done a demo that works, but it sure is ugly! Is there a better way? #!/bin/sh # Random... (12 Replies)
Discussion started by: wisecracker
12 Replies
rbox(1) 						      General Commands Manual							   rbox(1)

NAME
rbox - generate point distributions for qhull SYNOPSIS
Command "rbox" (w/o arguments) lists the options. DESCRIPTION
rbox generates random or regular points according to the options given, and outputs the points to stdout. The points are generated in a cube, unless 's' or 'k' option is given. The format of the output is the following: first line contains the dimension and a comment, sec- ond line contains the number of points, and the following lines contain the points, one point per line. Points are represented by their coordinate values. EXAMPLES
rbox 10 10 random points in the unit cube centered at the origin. rbox 10 s D2 10 random points on a 2-d circle. rbox 100 W0 100 random points on the surface of a cube. rbox 1000 s D4 1000 random points on a 4-d sphere. rbox c D5 O0.5 a 5-d hypercube with one corner at the origin. rbox d D10 a 10-d diamond. rbox x 1000 r W0 100 random points on the surface of a fixed simplex rbox y D12 a 12-d simplex. rbox l 10 10 random points along a spiral rbox l 10 r 10 regular points along a spiral plus two end points rbox 1000 L10000 D4 s 1000 random points on the surface of a narrow lens. rbox c G2 d G3 a cube with coordinates +2/-2 and a diamond with coordinates +3/-3. rbox 64 M3,4 z a rotated, {0,1,2,3} x {0,1,2,3} x {0,1,2,3} lattice (Mesh) of integer points. 'rbox 64 M1,0' is orthogonal. rbox P0 P0 P0 P0 P0 5 copies of the origin in 3-d. Try 'rbox P0 P0 P0 P0 P0 | qhull QJ'. r 100 s Z1 G0.1 two cospherical 100-gons plus another cospherical point. 100 s Z1 a cone of points. 100 s Z1e-7 a narrow cone of points with many precision errors. OPTIONS
n number of points Dn dimension n-d (default 3-d) Bn bounding box coordinates (default 0.5) l spiral distribution, available only in 3-d Ln lens distribution of radius n. May be used with 's', 'r', 'G', and 'W'. Mn,m,r lattice (Mesh) rotated by {[n,-m,0], [m,n,0], [0,0,r], ...}. Use 'Mm,n' for a rigid rotation with r = sqrt(n^2+m^2). 'M1,0' is an orthogonal lattice. For example, '27 M1,0' is {0,1,2} x {0,1,2} x {0,1,2}. '27 M3,4 z' is a rotated integer lattice. s cospherical points randomly generated in a cube and projected to the unit sphere x simplicial distribution. It is fixed for option 'r'. May be used with 'W'. y simplicial distribution plus a simplex. Both 'x' and 'y' generate the same points. Wn restrict points to distance n of the surface of a sphere or a cube c add a unit cube to the output c Gm add a cube with all combinations of +m and -m to the output d add a unit diamond to the output. d Gm add a diamond made of 0, +m and -m to the output Pn,m,r add point [n,m,r] to the output first. Pad coordinates with 0.0. n Remove the command line from the first line of output. On offset the data by adding n to each coordinate. t use time in seconds as the random number seed (default is command line). tn set the random number seed to n. z generate integer coordinates. Use 'Bn' to change the range. The default is 'B1e6' for six-digit coordinates. In R^4, seven-digit coordinates will overflow hyperplane normalization. Zn s restrict points to a disk about the z+ axis and the sphere (default Z1.0). Includes the opposite pole. 'Z1e-6' generates degener- ate points under single precision. Zn Gm s same as Zn with an empty center (default G0.5). r s D2 generate a regular polygon r s Z1 G0.1 generate a regular cone BUGS
Some combinations of arguments generate odd results. Report bugs to qhull_bug@qhull.org, other correspondence to qhull@qhull.org SEE ALSO
qhull(1) AUTHOR
C. Bradford Barber c/o The Geometry Center 400 Lind Hall 207 Church Street S.E. Minneapolis, MN 55455 Geometry Center August 10, 1998 rbox(1)
All times are GMT -4. The time now is 01:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy