You are here:

C++/Random Number


Dear David,

  i am john that ask you regarding the Random num. I want to generate the random number between -1 to 1. what function should i use and can you advise me on doing this? i need it urgently. thank alot for helping me at other section. i need your help quickly.

Best Regards

johntim , Thank you for your question.

Unfortunately, you did not state your Operating System, which might be Unix, Unix/XWindows, Sun OS, Windows 3.x, Windows 9x/ME, Windows NT/2000, Windows XP, MSDOS, MacOS, etc.

In addition, you did not state your program development environment, which might be Microsoft Visual C++/MFC, Visual C++/Win32, Borland Builder, Borland Turbo C++, Borland OWL, Unix/gcc, etc.

If you do not need a particularly good pseudorandom number, you can call the 'rand' function. This is available in most computer systems.

David Spector


All Answers

Answers by Expert:

Ask Experts


David Spector


Highly knowledgeable in the C++ language, Visual C++ (MSVC), Windows API, documentation and other quality-assurance techniques, and debugging. Knowledgeable in MFC, COM, GUI design, and object-oriented design.


I have been a software engineer since 1965. I have been published. My specializations have been: biomedical programming, compiler implementation, and many kinds of Windows programming. I don't do Databases or other business-oriented stuff.

Windows?/DOS Developer's Journal, ACM SIGPLAN Notices, and Computer Science Press.

ICCP Systems Programming Certification
Master's degree equivalent in Computer Science

©2016 All rights reserved.