question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide range-based numeric generators

See original GitHub issue

As discussed in #214, it would be useful for certain applications to provide a configurable range-based Double generator. Since the default Double generator is, by design, unable to compare two Double values as a consequence of the JVM specification, it would be nice to have a generator implementation which does not consider such extrema. Furthermore, since this behavior extends to other floating point types per the IEEE standard, it would be nice to circumvent these cases for the purposes of checking other numerical properties.

Further motivation for range-based generators would be to cover the space input values more extensively, for a smaller subset of the input domain.

@Kerooker

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
LeoColmancommented, Jan 8, 2019

This wouldn’t be hard to implement, we just have to figure out some nomenclature. I was thinking something like this:

  • Keep Gen.double() as it is (generating all possible doubles)
  • Have a Gen.numericDoubles() which would generate only numeric doubles (including a very very small one, close to -Infinity and a very very big one, close to +Infinity)
  • Have Gen.numericDoubles(minValue, maxValue) which would generate only numeric doubles, in the interval [minValue, maxValue]
0reactions
sksamuelcommented, Jan 8, 2019

exactDoubles, representableDoubles, numericDoubles

On Tue, 8 Jan 2019 at 12:53, Kerooker notifications@github.com wrote:

You stand correct. Only a subset of real numbers are representable.

I liked numericDoubles

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kotlintest/kotlintest/issues/530#issuecomment-452287742, or mute the thread https://github.com/notifications/unsubscribe-auth/AAtZGg7rPNnLw9gZ55V6WzHzYGTpALIsks5vBJTIgaJpZM4Z0s5u .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Random Number Generator - Calculator Soup
Random number generator for numbers 0 to 10000. Generate positive or negative pseudo-random numbers in your custom min-max range with repeats or no...
Read more >
Regex Numeric Range Generator — Regex Tools — 3Widgets
Generate regular expressions for numeric ranges. Just enter start and end of the range and get a valid regex. Works for both positive...
Read more >
Efficiently Generating a Number in a Range - pcg-random.org
Most modern good-quality random number generators produce machine words filled with random bits, thus typically generating numbers in the ...
Read more >
How to generate random number in given range using ...
Method 1: Using Math.random() function: The Math.random() function is used to return a floating-point pseudo-random number between range [0 ...
Read more >
Random Number Generator - Calculator.net
Two free random number generators that work in user-defined min and max range. Both random integers and decimal numbers can be generated with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found