473,587 Members | 2,463 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>
  6.  
  7. // These are the definitions of random number generators being used, 
  8.  
  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. }
  20.  
  21. // The calling functions 
  22.  
  23. srand48(time(NULL));
  24. srand64(time(NULL));........................line 778
  25.  
  26.  r1 = drand48();
  27.  r2 = drand64();................................line 783
  28.  
  29. /* . . . */
  30.  
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
Next_T:
^
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.

regards,
Aug 9 '07 #1
0 1896

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

Similar topics

1
3691
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?...
7
3917
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()
23
1763
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
5
3336
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...
15
597
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 ;-)
40
2795
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...
11
12803
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?
7
2508
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
16
539
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
0
7854
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,...
0
8349
jinu1996
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...
0
8221
tracyyun
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...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5395
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();...
0
3845
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...
1
2364
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
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.