473,837 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

random number generators

5 New Member
Hello everybody,
I have these errors on C program that may be because of random number definition. I use an SSH to compile C like in Linux. May be you have idea whether the errors are due to the random number generators in my program do not match those available from libraries in the SSH. My C program uses these libraries
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<math.h>
  4. #include<assert.h>
  5. #include<fftw3.h>
  7. // These are the definitions of random number generators being used, 
  9.  static unsigned long long int x = 1;
  10.  double drand64(void) .......................................................line 1781
  11. {
  12.    x = 6364136223846793005ll * x + (long long int) 1;  
  13.    return (double) x * 5.4210108624275218e-20; 
  14. }
  15. void srand64(int seed).......................................................line 1787
  16. {
  17.    assert(sizeof(long long int) == 8);
  18.    x = seed;
  19. }
  21. // The calling functions 
  23. srand48(time(NULL));
  24. srand64(time(NULL));........................line 778
  26.  r1 = drand48();
  27.  r2 = drand64();................................line 783
  29. /* . . . */
When I compile using icc, there are several warnings on random number generators

GlobalRevows.c( 192): warning #181: argument is incompatible with corresponding format string conversion
sizeof(real), (double) h, MAX, MAX_pass);
GlobalRevows.c( 778): warning #266: function declared implicitly
srand64(time(NU LL));
GlobalRevows.c( 783): warning #266: function declared implicitly
r2 = drand64();
GlobalRevows.c( 791): warning #266: function declared implicitly
r2 = drand64();
GlobalRevows.c( 800): warning #177: label "Next_T" was declared but never referenced
GlobalRevows.c( 1780): warning #159: declaration is incompatible with previous "drand64" (declared at line 783)
double drand64(void)
GlobalRevows.c( 1786): warning #159: declaration is incompatible with previous "srand64" (declared at line 778)
void srand64(int seed)
GlobalRevows.c( 1792): error: variable "x" has already been initialized
static unsigned long long int x = 1;
GlobalRevows.c( 1800): warning #147: declaration is incompatible with "void srand48(long)" (declared at line 522 of "/usr/include/stdlib.h")
void srand48(int seed)
Compiling with gcc gives errors something like this;

GlobalRevows1.c :1781: error: conflicting types for 'drand64'
GlobalRevows1.c :783: error: previous implicit declaration of 'drand64' was here
GlobalRevows1.c :1787: error: conflicting types for 'srand64'
GlobalRevows1.c :778: error: previous implicit declaration of 'srand64' was here
I have tried many alternative ways but none works. Any suggestion would be appreciated.

Aug 9 '07 #1
0 1908

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Brandon Michael Moore | last post by:
I'm trying to test a web application using a tool written in python. I would like to be able to generate random values to put in fields. I would like to be able to generate random dates (in a specified range), random strings (specifying allowed characters and a distribution of lengths), or choose randomly between several generators (for better control of the distribution of values). Is there any library for this sort of thing in Python?...
by: Ioannis Vranos | last post by:
I want to create some random numbers for encryption purposes, and i wonder if the following scheme makes it more hard to guess the underneath number generation pattern, than the plain use of rand(): #include <cstdlib> #include <ctime> int GetRandomNumber()
by: MConly | last post by:
Can you tell me what happens inside CPU when I rand() ? Where can I find the true rand function implemented ? I have heard that rand() in C/C++ is n't a good one but why it isn't a good one, are they lying to me ? Why do they have to do that ? Thank you MnConly
by: Peteroid | last post by:
I know how to use rand() to generate random POSITIVE-INTEGER numbers. But, I'd like to generate a random DOUBLE number in the range of 0.0 to 1.0 with resolution of a double (i.e., every possible double value in the range could come up with equal probability). I'd also like to be able to seed this generator (e.g., via the clock) so that the same sequence of random values don't come up every time. Anybody have an easy and fast...
by: felixnielsen | last post by:
This is something i have done before and i know its pretty simple, however i cant remember how it works exactly, and i need it i kinda hurry, so if someone would be so nice to drop a random number generator (actually i just need binary 1 or 0) i would be forever gratefull ;-)
by: RadiationX | last post by:
I have a problem that I really don't understand at all. In my previous post I could get started on my projects I just had a few problems with syntax errors. This problem is something that I don't conceptually understand very well. Here it is: Π – the ratio of the circumference of a circle to its diameter – is one of the most common and important constants in mathematics. It is an irrational number (a real number that cannot be...
by: TreatmentPlant | last post by:
I need to generate a few thousand true random numbers using C++. I have some code now that does alright, but when you plot the results on a graph, you notice patterns, so the numbers are not truly random, but pseudo-random. I tried randomly seeding the seed! to see if that improved things; it didn't. Can anyone help?
by: BillG | last post by:
Hi, Does anyone know of a site or have code for a function that will generate a random string or random number? I need one where I can tell it what type of value I need and where I can set the length of the desired output. Thanks
by: jason.cipriani | last post by:
I am looking for a random number generator implementation with the following requirements: - Thread-safe, re-entrant. - Produces consistently reproducible sequences of psuedo-random numbers given a seed. - Relatively uniform, does not have to be perfect. The application is not a security or statistics application, the quality of numbers is not a priority although a fairly uniform
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.