Yawnder
Yawnder
CC#
Created by Mango on 2/13/2025 in #help
Need an extension method to generate a random decimal within a range
Anyhow, gtg. You already have many ways to skin the cat.
70 replies
CC#
Created by Mango on 2/13/2025 in #help
Need an extension method to generate a random decimal within a range
You could be lazy then... rnd.Next(-30000M,30000M)/100M
70 replies
CC#
Created by Mango on 2/13/2025 in #help
Need an extension method to generate a random decimal within a range
No. There is nothing in the requirements that talks about rounding. If "good enough" is the requirement, good enough is good enough.
70 replies
CC#
Created by Mango on 2/13/2025 in #help
Need an extension method to generate a random decimal within a range
(ignore the scale difference in my sarcastic message)
70 replies
CC#
Created by Mango on 2/13/2025 in #help
Need an extension method to generate a random decimal within a range
And it might not be perfectly distributed. Like you might get more or less chances of getting a number between 0.947259863249856 and 0.947259863249857 and you would between 0.4397747587 and 0.4397747588
70 replies
CC#
Created by Mango on 2/13/2025 in #help
Need an extension method to generate a random decimal within a range
public static decimal MyThing(this Random rnd, decimal lowerBound, decimalUpperBound)
{
// Guard for lower < upper
return (upperBound-lowerBound)*(decimal)rnd.NextDouble()+lowerBound;
}
public static decimal MyThing(this Random rnd, decimal lowerBound, decimalUpperBound)
{
// Guard for lower < upper
return (upperBound-lowerBound)*(decimal)rnd.NextDouble()+lowerBound;
}
70 replies
CC#
Created by Mango on 2/13/2025 in #help
Need an extension method to generate a random decimal within a range
Ok, so you want to use the same seed? Alright. Do you have a requirement that the random has to be "perfect", or just "quite good enough"?
70 replies
CC#
Created by Mango on 2/13/2025 in #help
Need an extension method to generate a random decimal within a range
Ok. You want to extend what?
70 replies
CC#
Created by Mango on 2/13/2025 in #help
Need an extension method to generate a random decimal within a range
@A Certain Scientific Railgun Where does the "has to be an extension method" requirement comes from?
70 replies
CC#
Created by Leandro on 2/9/2025 in #help
refactor database to stop using UNIQUEIDENTIFIER as PK
I have to go for now though, sorry.
60 replies
CC#
Created by Leandro on 2/9/2025 in #help
refactor database to stop using UNIQUEIDENTIFIER as PK
I'd guess a non-indexed column, but even so.
60 replies
CC#
Created by Leandro on 2/9/2025 in #help
refactor database to stop using UNIQUEIDENTIFIER as PK
Oh, that has nothing to do with PKs then
60 replies
CC#
Created by Leandro on 2/9/2025 in #help
refactor database to stop using UNIQUEIDENTIFIER as PK
Also, how are they generated? By the database or by the code?
60 replies
CC#
Created by lime_soft on 2/4/2025 in #help
Entity Framework Core updating tables in navigation fields
You either do a roundtrip to get Baz first, or you use ExecuteUpdate.
4 replies
CC#
Created by VoidPointer on 1/22/2025 in #help
Appsettings not mapping to Options class
You don't need the bind afaik.
17 replies
CC#
Created by VoidPointer on 1/22/2025 in #help
Appsettings not mapping to Options class
Where is CassandraOptions registered? I'd expect to see something like builder.Services.Configure<CassandraOptions>(builder.Configuration.GetSection("Cassandra"));
17 replies
CC#
Created by Fat Lenny on 9/21/2024 in #help
difference between a normal variable and one declared with that property shorthand garbage
Let me get this straight: You don't understand something, and you go about calling it garbage, and you expect a positive response?
40 replies
CC#
Created by Denge on 9/4/2024 in #help
Testing multi layered .NET application
I don't see what isn't done properly based on your code, but if it returns null, then there must be something wrong.
4 replies
CC#
Created by Denge on 9/4/2024 in #help
Testing multi layered .NET application
Which probably leads to the actual issue: You probably didn't do the setup of your mocks.
4 replies