Skip to content

Fix Issue 15720 - iota(long.max, long.min, step) does not work properly#5397

Merged
dlang-bot merged 1 commit intodlang:masterfrom
andralex:15720
May 16, 2017
Merged

Fix Issue 15720 - iota(long.max, long.min, step) does not work properly#5397
dlang-bot merged 1 commit intodlang:masterfrom
andralex:15720

Conversation

@andralex
Copy link
Member

Practically reopening #5396

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
15720 iota(long.max, long.min, step) does not work properly

auto t1 = iota(0, 10, 2);
auto t2 = iota(1, 1, 0);
//float overloads use std.conv.to so can't be @nogc or nothrow
alias ssize_t = Unsigned!size_t;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, wasn't this supposed to say Signed!size_t?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't believe I messed that up! brb

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no failure... "everything turned out better than expected"

@CyberShadow
Copy link
Member

Issue 15720 says the expected output is:

18446744073709551615
9223372036854775807
6148914691236517205

With this PR, the test case in 15720 prints:

18446744073709551615
9223372036854775808
6148914691236517205

The second number is off by one. Which one is correct?

@andralex
Copy link
Member Author

My reasoning went as follows. For simplicity, let's reduce the matter to 1-nibble numbers. So then we have iota(7, -8, -2) and the question is whether there are an odd (8) or an even (7) count in there.

So we have 7, 5, 3, 1, -1, -3, -5, -7 so 8 numbers total.

@CyberShadow
Copy link
Member

Same result here.

// iota
/**
Construct a range of values that span the given starting and stopping
Creates a range of values that span the given starting and stopping
Copy link
Member

@MetaLang MetaLang May 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not complaining, but why the change from "construct" to "creates"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This guy construct" -> no predicate. "This guy constructs" -> good. "This guy creates" -> even better.

Copy link
Member

@MetaLang MetaLang May 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This guy allows you to construct"

But Occam's Razor tells me that "creates" is probably better.

Copy link
Member

@MetaLang MetaLang May 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I'm almost as interested in natural languages as I am in programming languages, I was interested in seeing if there was any correct answer. Congrats, you piqued my curiosity ;-)

@dlang-bot dlang-bot merged commit 138d9b9 into dlang:master May 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants