Programming :: Using /dev/random To Generate Double?
Mar 6, 2010
I need to generate random numbers using /dev/random in C. The numbers should be of type double (64-bit floating point).The functionality should be equal to linux command "od -An -N8 -t fD /dev/random", but written in C.The prototype should be "double drand(void);".
View 7 Replies
ADVERTISEMENT
Aug 3, 2010
A script to generate random dates. It uses the year range 2006-2009, and truncates every month of the year to an ordinary February's 28 days, but otherwise it's pretty solid and safe.
Code:
spate=1
while [ $spate -le 120 ]
[code]....
View 1 Replies
View Related
Jan 21, 2010
Not only that but I need tons and tons of them generated, and I need it to be totally random each time.
Code:
matthew@mvm:/h/misc> cat a
#!/bin/bash
for i in {1..5}; do
echo $RANDOM
[Code]....
There you can see that it is the same number. It does that every time!! Grrr. The strange thing is each time I manually type [or copy & paste] it into the terminal, it gives random [not static, like I am getting from my script] results.
The reason I want this is because I am making a script where this line will randomly go up or down [depending on if the random number is 1 or 0].
View 4 Replies
View Related
Aug 24, 2010
I have this: Code: dd if=/dev/urandom count=128 bs=1 2>&1 | md5 | cut -b-10 But I only want it to have letters and no numbers. What can I do for this?
View 13 Replies
View Related
Jul 20, 2011
List of 77 lines with the names of movies. For ease, let's say it's in a text file. What I want is a command line argument I can pass that'll read each line and pick one of those 77 lines at random, except I can't figure out how to do this. Is there a program I can just pipe the output of 'cat listofmovies.txt' to?
View 13 Replies
View Related
Mar 4, 2010
I want to generate a temporary random list from a directory of files and then determine the size of an arbitrary block of files from this list (say 1-25 or 26-50) and add their names to a file along with some other info for each name. I can generate a random list with file sizes like this: ls -l | sort -R | cut -d " " -f 6 but i'm not sure how to add up the sizes of just a certain block of these files and at the same time save the file names.
View 2 Replies
View Related
Apr 9, 2011
Since I enjoyed Gnome shell with Ubuntu 9.10 (but Ubuntu runs too slow on this computer for my druthers), I thought it would be fun to check out gnome shell on 11.3. I thought that since my 11.3 has gnome 2.30, that the gnome shell in the software manager would be a concomitant version, so I installed it. I then followed the directions given in the second posting of Enabling Gnome Shell in 11.3?
When I logged back in, I selected Gnome 3 Preview [even though I hadn't thought that that was what I'd installed -- (has openSUSE retired all older versions of Gnome shell?)]. The desktop won't boot (I don't know what the correct way of saying it is). The splash shows, but the icons just intermittently flash off and on at random intervals, never quite making it all the way "on." When I right click the bottom of the screen, I can select "terminal" (when I can accurately coordinate my double-click with the random, intermittent flashing), but then the terminal also does the random, intermittent flashing as well. So I can never get anything typed in. When I reboot, there's no login box.
View 5 Replies
View Related
Jun 6, 2010
In bash I need to use some equivalent of double quotes inside double quotes (or the other way around.)I need to run the following statement to get the output of foo and store it in a variable while passing foo the $file which probably contains spaces.
Code:
variable=$(foo "$file")
The problem is that foo might return an empty string and if it does I need to catch it
[code]...
View 6 Replies
View Related
Mar 31, 2010
How can I generate a md5 or sha-1 code with perl?
View 2 Replies
View Related
Dec 2, 2014
How do I generate sql result into xml ? Tried this way (shown below), but it generates all data into single column.
Code: Select allgenerate_xml()
{
f1=_tmp1
f2=_tmp2
cat $SQL_QUERY_OUT |sed -e 's/^"//g;s/"$//g;s/","/|/g'|tr '|' ' ' > $f1
[ -e $SQL_QUERY_OUT ] && rm $SQL_QUERY_OUT
[code]....
View 2 Replies
View Related
Feb 24, 2011
Does anybody know how to generate excel charts from C, or if it's possible at all?
For example, if I had 2 arrays that I wanted to export to excel and graph against each other. I know how to export it to a csv file, that's no problem, but I have no idea where to start with generating a graph of the data. I can't seem to find any examples anywhere.
I'd appreciate if someone could point me in the right direction.
Just a simple example to show you what I mean code...
View 10 Replies
View Related
Jun 24, 2010
I have a file, two columns, first column has a list of 15000 (yes 15k) unique codes, second column has the afilliate codes of 60 locations repeated to fill out the 15000 rows of unique codes. I need to produce a nice neat paper voucher which will fit onto A6 (1/4 A4) and is ready to print. Each voucher has the unique code and corresponding location. So far I am thinking PHP will do the job. This does it somewhat, but doesn't let be split the fields between the ",". I did this so far in PHP
[Code]...
View 3 Replies
View Related
May 19, 2009
I am trying to generate pdf in thai language. i have installed thai package (extension in babel package). It is finally generating pdf in thai. but thai string are cming very long as compared to original string given in .tex file.
View 3 Replies
View Related
Apr 5, 2010
Someone know how i can convert from hex string to double in c/c++?? Example 40668472B020C49C is 180.139
reference page: http://babbage.cs.qc.edu/IEEE-754/64bit.html
View 10 Replies
View Related
Mar 24, 2011
We are running some script to generate below values however we don't need the first level output as it always shows cpu % as 0.0.
(We dont need following part:
NAME STATE CPU(sec) CPU(%)
XXX -----r 55567 0.0
[code]....
View 10 Replies
View Related
Apr 18, 2010
I want to automate my System-installation. So i try to make a Script that will generate the /etc/motd. Now i have the Problem that the script has some variables and after the "Hostname, OS, HW, IP" the "stars" are anyware, but not there they should. The most problem is the $OS this string can verry long or verry short be. Fedora release 12 (Constantine) or RedHat 5.4 i can do that after the variables place the "stars" on the write position?
Script
Code:
#!/bin/bash
[code]....
View 6 Replies
View Related
Sep 7, 2010
I have some c++ code and want to generate class diagrams using some tool which would scan the c++ code and generate diagrams. Is there any such open source tool to be used on linux machine?
View 1 Replies
View Related
Nov 4, 2010
I'm trying to write a bash script that has to extract values from a csv file. Problem is there are lines like this:a,b,c,"dd,dd,dd",e,f,gI'm using awk to extract the values but when I try it extract value 4 with awk I get:"ddinstead of:"dd,dd,dd"Does anyone know how to get awk to ignore commas within double quotes?
View 5 Replies
View Related
Nov 23, 2010
in c/c++, double is usually 8 bytes. It has a 52-bit mantissa (or significand, or base), an 11-bit exponent, and a 1-bit sign. My question is: is the mantissa a 52-bit integer? Or is the decimal point just after the first bit. Meaning: if the mantissa was 1000110011100011 (in binary) would that make the value of the mantissa (assuming the exponent was 0) 1000110011100011, or 1.000110011100011? (in binary)
View 1 Replies
View Related
Jun 3, 2011
Code:
int main ()
{
[code]...
View 9 Replies
View Related
May 10, 2010
Here's my code for bubble sort with double type
Code:
#include <stdio.h>
void swap_double( double *a, double *b )
{
double _t = *a;
code....
View 1 Replies
View Related
Jul 20, 2011
grep -e XkbLayout /etc/X11/xorg.conf | grep -v "^#" | awk '{print $3}'
output = "gb"
sometimes= "us"
View 4 Replies
View Related
Jan 21, 2010
I want to convert double quote to single quote in a text file. I tried escape characters however no success. Please find details as follows:
-sh-3.00$ sed 's/"/'/g test.txt
sed: -e expression #1, char 7: unterminated `s' command
-sh-3.00$ cat test.txt
"unix"
I want "unix" to be converted to 'unix'
View 7 Replies
View Related
Jan 20, 2011
can i get the ocuurance of left click-right click-double click?i need the time of ocurance and the click(left-right-double) that happend.any software?any clue..i need it in linux environment(kde or gnome)
View 14 Replies
View Related
Dec 21, 2014
I have both 32 bit and 64 bit libs installed with gcc multilib.
I tried following options, but the result is still a 32bit elf:
# cc -mips64 -mabi=o64 -mlong64 -mgp64 -c gendian.c
# file gendian.o
gendian.o: ELF 32-bit LSB relocatable, MIPS, MIPS64 version 1 (SYSV), with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x1040000, not stripped
The machine is running 64 bit os:
# uname -a
Linux debian 3.2.0-4-5kc-malta #1 Debian 3.2.63-2+deb7u2 mips64 GNU/Linux
Both 4.6 and 4.7 gcc have been tried, and both have the same issue.
Fixed: need -mabi=64
View 0 Replies
View Related
Oct 8, 2010
I want to write a program in C which will generate a maze randomly and find the solution for it ..
The idea behind is in [url]
How the 16 bit integer is stored in a variable..Earlier I wrote a program on trees and displayed it using dotty.. Is there any such tool to display a maze..I am using ubuntu 10.04.
View 1 Replies
View Related
Apr 5, 2011
i have spotted that script (something similar that i am looking for)
[URL]
and i just dont know how to use it.I am not a programmer myself and probably no need for learning that just to create one script! modify "wje_lq" script and run it. thing like : "Just redirect standard output to a file in the normal manner" ? and all this
I.Comment out the first definition of *character-set*, by adding a semicon at the beginning of the line.
II.Uncomment the second definition, which just uses "ABC", by removing the semicolon from the beginning of the line.
III.Comment out the first definition of *word-length*.
IV.Uncomment the second definition, which uses a word length of four.
i would like to generate :
10-character combinations of the following characters (lowercase) 23456789abcdef with no more then 3 same letters repeates no metter side by side or within one line (sequence) so lets say
abcdef1234 accept
fabcde1234 accept
ffabcd1234 accept
which is probably permutation with repetable string ( where abc is not equeal to cba etc .so ti speak position does metter)
fffabc1234 not acceptable -----(3 same characters)
ffabcf1234 not acceptable -----( 3 same characters event thought not side by side)
we dont want 3 same characters apper in same line.
View 2 Replies
View Related
Aug 12, 2010
I'm trying to write an extension to PHP which means coding in C. I'm really really rusty at C coding and was never very good at it.
Can anyone propose an efficient, safe, and [hopefully] future-proof way of reversing a double? Keep in mind that it should work on as many systems as possible and on 32- and 64-bit systems (and on ???-bit systems in the future?). Will the size of a 'double' ever change or will it always be 8 bytes?
I've tried this and it doesn't work...the compiler complains about "invalid operands to binary" because I'm trying bitwise shiftw on a non-integer.
Code:
x = (x>>56) |
((x<<40) & 0x00FF000000000000) |
((x<<24) & 0x0000FF0000000000) |
((x<<8) & 0x000000FF00000000) |
[Code]....
View 3 Replies
View Related
Mar 27, 2010
I have tryed out this operator on program:
Code:
#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
ofstream myfile;
[code]...
which definitly is not the same number. I guess somewhere in the convertion from double to char* ("<<") something is not right and what can i do to save these double numbers in an accurate manner in a file?
View 14 Replies
View Related
Mar 18, 2010
I have been battling with regular expressions and am a little lost. I want to find all my files that end with .la and have been trying this
Code:
slocate -r .la$
which finds them but also files like mozilla. The escaped full stop seems to be ignored however this works :
Code:
slocate -r \.la$
so why is the double escaping needed ?
View 3 Replies
View Related