Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Generating Random Decimals between Two Decimals [duplicate]

Tags:

c#

random

decimal

EDIT I will re-explain, whenever I say decimal, I mean system.decimal not the mathematical concept

decimal min = 5.62;
decimal max = 14.39;

How would I get a system.decimal that is randomly between the range of the above two decimals?

Double != system.decimal

FYI I don't know how I can make my question clearer since more than half the people that read this only read 2 words and then flagged it as a duplicate.

like image 992
BananaPoop Avatar asked Jan 26 '12 16:01

BananaPoop


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is C language?

C is an imperative procedural language supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support.

Is C language easy?

Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.

What is C full form?

Full form of C is “COMPILE”. One thing which was missing in C language was further added to C++ that is 'the concept of CLASSES'.


1 Answers

y=mx+c. Generate a 0<=X<1 FP random with NextDouble(), multiply it up by (Dmax-Dmin) into the right range, then add Dmin to shift the base.

like image 177
Martin James Avatar answered Nov 14 '22 23:11

Martin James