[jira] [Work logged] (LANG-1627) BooleanUtils.xor not behaving as expected with any odd number of true's

2022-07-05 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1627?focusedWorklogId=788018&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-788018
 ]

ASF GitHub Bot logged work on LANG-1627:


Author: ASF GitHub Bot
Created on: 05/Jul/22 19:05
Start Date: 05/Jul/22 19:05
Worklog Time Spent: 10m 
  Work Description: garydgregory closed pull request #890: [LANG-1627] 
Implement xorOneHot and add clarifications to Javadoc for xor to explain when 
it returns true
URL: https://github.com/apache/commons-lang/pull/890




Issue Time Tracking
---

Worklog Id: (was: 788018)
Time Spent: 1h 40m  (was: 1.5h)

> BooleanUtils.xor not behaving as expected with any odd number of true's
> ---
>
> Key: LANG-1627
> URL: https://issues.apache.org/jira/browse/LANG-1627
> Project: Commons Lang
>  Issue Type: Bug
>Affects Versions: 3.11
>Reporter: Alberto Scotto
>Priority: Major
>  Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> Hi,
> I was expecting a xor function that takes a variable number of arguments to 
> *return true if and only if exactly one among all of the arguments is true*, 
> regardless of the number of arguments.
> This holds true given three false's:
> {code:java}
> @Test
> public void threeFalse() {
>  boolean[] bools = new boolean[]{Boolean.FALSE, Boolean.FALSE, Boolean.FALSE};
>  assertFalse(BooleanUtils.xor(bools));
> }{code}
>  
>  It also holds true given 4 true's, as well as for any even number of trues.
> {code:java}
> @Test
> public void fourTrue() {
> boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, 
> Boolean.TRUE, Boolean.TRUE};
> assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> The above tests pass.
> But with any odd number of true's that doesn't hold anymore:
>  
> {code:java}
> @Test
> public void threeTrue() {
>  boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, Boolean.TRUE};
>  assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> This test fails.
> That was totally unexpected to me.
>  But as it turns out, even
> {noformat}
> true ^ true ^ true{noformat}
> evaluates to true. That was unexpected too to me, at a first sight.
> The thing is that xor (I mean the original boolean operator) is a binary 
> operator, so if you want to make it n-ary, one simple solution is to apply it 
> in two by two: ((a ^ b) ^ c) ^ d
>  And that's what is done in the implementation of the method BooleanUtils#xor.
> But that brings to BooleanUtils.xor(true, true, true) == true, and at the 
> same time BooleanUtils.xor(true, true, true, true) == false, which just 
> doesn't sound right to me.
> Whether or not you agree with me that that is a bug of the method, please at 
> least update the Javadoc, because right now it is not providing the user 
> enough information. Look:
> {code:java}
> Performs an xor on a set of booleans.
>  BooleanUtils.xor(true, true)   = false
>  BooleanUtils.xor(false, false) = false
>  BooleanUtils.xor(true, false)  = true
> {code}
>  
> Thanks.
> Cheers



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Work logged] (LANG-1627) BooleanUtils.xor not behaving as expected with any odd number of true's

2022-07-05 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1627?focusedWorklogId=788017&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-788017
 ]

ASF GitHub Bot logged work on LANG-1627:


Author: ASF GitHub Bot
Created on: 05/Jul/22 19:05
Start Date: 05/Jul/22 19:05
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on PR #890:
URL: https://github.com/apache/commons-lang/pull/890#issuecomment-1175402822

   Closing: I brought this in slightly differently, using `oneHot()` instead of 
`xorOneHot` and other minor changes; please see git master.




Issue Time Tracking
---

Worklog Id: (was: 788017)
Time Spent: 1.5h  (was: 1h 20m)

> BooleanUtils.xor not behaving as expected with any odd number of true's
> ---
>
> Key: LANG-1627
> URL: https://issues.apache.org/jira/browse/LANG-1627
> Project: Commons Lang
>  Issue Type: Bug
>Affects Versions: 3.11
>Reporter: Alberto Scotto
>Priority: Major
>  Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> Hi,
> I was expecting a xor function that takes a variable number of arguments to 
> *return true if and only if exactly one among all of the arguments is true*, 
> regardless of the number of arguments.
> This holds true given three false's:
> {code:java}
> @Test
> public void threeFalse() {
>  boolean[] bools = new boolean[]{Boolean.FALSE, Boolean.FALSE, Boolean.FALSE};
>  assertFalse(BooleanUtils.xor(bools));
> }{code}
>  
>  It also holds true given 4 true's, as well as for any even number of trues.
> {code:java}
> @Test
> public void fourTrue() {
> boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, 
> Boolean.TRUE, Boolean.TRUE};
> assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> The above tests pass.
> But with any odd number of true's that doesn't hold anymore:
>  
> {code:java}
> @Test
> public void threeTrue() {
>  boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, Boolean.TRUE};
>  assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> This test fails.
> That was totally unexpected to me.
>  But as it turns out, even
> {noformat}
> true ^ true ^ true{noformat}
> evaluates to true. That was unexpected too to me, at a first sight.
> The thing is that xor (I mean the original boolean operator) is a binary 
> operator, so if you want to make it n-ary, one simple solution is to apply it 
> in two by two: ((a ^ b) ^ c) ^ d
>  And that's what is done in the implementation of the method BooleanUtils#xor.
> But that brings to BooleanUtils.xor(true, true, true) == true, and at the 
> same time BooleanUtils.xor(true, true, true, true) == false, which just 
> doesn't sound right to me.
> Whether or not you agree with me that that is a bug of the method, please at 
> least update the Javadoc, because right now it is not providing the user 
> enough information. Look:
> {code:java}
> Performs an xor on a set of booleans.
>  BooleanUtils.xor(true, true)   = false
>  BooleanUtils.xor(false, false) = false
>  BooleanUtils.xor(true, false)  = true
> {code}
>  
> Thanks.
> Cheers



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Work logged] (LANG-1627) BooleanUtils.xor not behaving as expected with any odd number of true's

2022-05-11 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1627?focusedWorklogId=768986&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-768986
 ]

ASF GitHub Bot logged work on LANG-1627:


Author: ASF GitHub Bot
Created on: 11/May/22 10:48
Start Date: 11/May/22 10:48
Worklog Time Spent: 10m 
  Work Description: kinow commented on PR #890:
URL: https://github.com/apache/commons-lang/pull/890#issuecomment-1123567152

   >Merged two PRs and squashed.
   
   Thanks!
   
   >First time I've attempted a squash, please let me know if I've done 
anything wrong
   
   It's perfect now! All that's left now is review the code :) thanks 
@stevebosman-oc !




Issue Time Tracking
---

Worklog Id: (was: 768986)
Time Spent: 1h 20m  (was: 1h 10m)

> BooleanUtils.xor not behaving as expected with any odd number of true's
> ---
>
> Key: LANG-1627
> URL: https://issues.apache.org/jira/browse/LANG-1627
> Project: Commons Lang
>  Issue Type: Bug
>Affects Versions: 3.11
>Reporter: Alberto Scotto
>Priority: Major
>  Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> Hi,
> I was expecting a xor function that takes a variable number of arguments to 
> *return true if and only if exactly one among all of the arguments is true*, 
> regardless of the number of arguments.
> This holds true given three false's:
> {code:java}
> @Test
> public void threeFalse() {
>  boolean[] bools = new boolean[]{Boolean.FALSE, Boolean.FALSE, Boolean.FALSE};
>  assertFalse(BooleanUtils.xor(bools));
> }{code}
>  
>  It also holds true given 4 true's, as well as for any even number of trues.
> {code:java}
> @Test
> public void fourTrue() {
> boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, 
> Boolean.TRUE, Boolean.TRUE};
> assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> The above tests pass.
> But with any odd number of true's that doesn't hold anymore:
>  
> {code:java}
> @Test
> public void threeTrue() {
>  boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, Boolean.TRUE};
>  assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> This test fails.
> That was totally unexpected to me.
>  But as it turns out, even
> {noformat}
> true ^ true ^ true{noformat}
> evaluates to true. That was unexpected too to me, at a first sight.
> The thing is that xor (I mean the original boolean operator) is a binary 
> operator, so if you want to make it n-ary, one simple solution is to apply it 
> in two by two: ((a ^ b) ^ c) ^ d
>  And that's what is done in the implementation of the method BooleanUtils#xor.
> But that brings to BooleanUtils.xor(true, true, true) == true, and at the 
> same time BooleanUtils.xor(true, true, true, true) == false, which just 
> doesn't sound right to me.
> Whether or not you agree with me that that is a bug of the method, please at 
> least update the Javadoc, because right now it is not providing the user 
> enough information. Look:
> {code:java}
> Performs an xor on a set of booleans.
>  BooleanUtils.xor(true, true)   = false
>  BooleanUtils.xor(false, false) = false
>  BooleanUtils.xor(true, false)  = true
> {code}
>  
> Thanks.
> Cheers



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Work logged] (LANG-1627) BooleanUtils.xor not behaving as expected with any odd number of true's

2022-05-11 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1627?focusedWorklogId=768962&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-768962
 ]

ASF GitHub Bot logged work on LANG-1627:


Author: ASF GitHub Bot
Created on: 11/May/22 09:59
Start Date: 11/May/22 09:59
Worklog Time Spent: 10m 
  Work Description: stevebosman-oc commented on PR #890:
URL: https://github.com/apache/commons-lang/pull/890#issuecomment-1123480378

   Merged two PRs and squashed. First time I've attempted a squash, please let 
me know if I've done anything wrong
   




Issue Time Tracking
---

Worklog Id: (was: 768962)
Time Spent: 1h 10m  (was: 1h)

> BooleanUtils.xor not behaving as expected with any odd number of true's
> ---
>
> Key: LANG-1627
> URL: https://issues.apache.org/jira/browse/LANG-1627
> Project: Commons Lang
>  Issue Type: Bug
>Affects Versions: 3.11
>Reporter: Alberto Scotto
>Priority: Major
>  Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> Hi,
> I was expecting a xor function that takes a variable number of arguments to 
> *return true if and only if exactly one among all of the arguments is true*, 
> regardless of the number of arguments.
> This holds true given three false's:
> {code:java}
> @Test
> public void threeFalse() {
>  boolean[] bools = new boolean[]{Boolean.FALSE, Boolean.FALSE, Boolean.FALSE};
>  assertFalse(BooleanUtils.xor(bools));
> }{code}
>  
>  It also holds true given 4 true's, as well as for any even number of trues.
> {code:java}
> @Test
> public void fourTrue() {
> boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, 
> Boolean.TRUE, Boolean.TRUE};
> assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> The above tests pass.
> But with any odd number of true's that doesn't hold anymore:
>  
> {code:java}
> @Test
> public void threeTrue() {
>  boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, Boolean.TRUE};
>  assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> This test fails.
> That was totally unexpected to me.
>  But as it turns out, even
> {noformat}
> true ^ true ^ true{noformat}
> evaluates to true. That was unexpected too to me, at a first sight.
> The thing is that xor (I mean the original boolean operator) is a binary 
> operator, so if you want to make it n-ary, one simple solution is to apply it 
> in two by two: ((a ^ b) ^ c) ^ d
>  And that's what is done in the implementation of the method BooleanUtils#xor.
> But that brings to BooleanUtils.xor(true, true, true) == true, and at the 
> same time BooleanUtils.xor(true, true, true, true) == false, which just 
> doesn't sound right to me.
> Whether or not you agree with me that that is a bug of the method, please at 
> least update the Javadoc, because right now it is not providing the user 
> enough information. Look:
> {code:java}
> Performs an xor on a set of booleans.
>  BooleanUtils.xor(true, true)   = false
>  BooleanUtils.xor(false, false) = false
>  BooleanUtils.xor(true, false)  = true
> {code}
>  
> Thanks.
> Cheers



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Work logged] (LANG-1627) BooleanUtils.xor not behaving as expected with any odd number of true's

2022-05-11 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1627?focusedWorklogId=768958&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-768958
 ]

ASF GitHub Bot logged work on LANG-1627:


Author: ASF GitHub Bot
Created on: 11/May/22 09:57
Start Date: 11/May/22 09:57
Worklog Time Spent: 10m 
  Work Description: stevebosman-oc closed pull request #891: [LANG-1627] 
New method for One-hot XOR
URL: https://github.com/apache/commons-lang/pull/891




Issue Time Tracking
---

Worklog Id: (was: 768958)
Time Spent: 1h  (was: 50m)

> BooleanUtils.xor not behaving as expected with any odd number of true's
> ---
>
> Key: LANG-1627
> URL: https://issues.apache.org/jira/browse/LANG-1627
> Project: Commons Lang
>  Issue Type: Bug
>Affects Versions: 3.11
>Reporter: Alberto Scotto
>Priority: Major
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Hi,
> I was expecting a xor function that takes a variable number of arguments to 
> *return true if and only if exactly one among all of the arguments is true*, 
> regardless of the number of arguments.
> This holds true given three false's:
> {code:java}
> @Test
> public void threeFalse() {
>  boolean[] bools = new boolean[]{Boolean.FALSE, Boolean.FALSE, Boolean.FALSE};
>  assertFalse(BooleanUtils.xor(bools));
> }{code}
>  
>  It also holds true given 4 true's, as well as for any even number of trues.
> {code:java}
> @Test
> public void fourTrue() {
> boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, 
> Boolean.TRUE, Boolean.TRUE};
> assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> The above tests pass.
> But with any odd number of true's that doesn't hold anymore:
>  
> {code:java}
> @Test
> public void threeTrue() {
>  boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, Boolean.TRUE};
>  assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> This test fails.
> That was totally unexpected to me.
>  But as it turns out, even
> {noformat}
> true ^ true ^ true{noformat}
> evaluates to true. That was unexpected too to me, at a first sight.
> The thing is that xor (I mean the original boolean operator) is a binary 
> operator, so if you want to make it n-ary, one simple solution is to apply it 
> in two by two: ((a ^ b) ^ c) ^ d
>  And that's what is done in the implementation of the method BooleanUtils#xor.
> But that brings to BooleanUtils.xor(true, true, true) == true, and at the 
> same time BooleanUtils.xor(true, true, true, true) == false, which just 
> doesn't sound right to me.
> Whether or not you agree with me that that is a bug of the method, please at 
> least update the Javadoc, because right now it is not providing the user 
> enough information. Look:
> {code:java}
> Performs an xor on a set of booleans.
>  BooleanUtils.xor(true, true)   = false
>  BooleanUtils.xor(false, false) = false
>  BooleanUtils.xor(true, false)  = true
> {code}
>  
> Thanks.
> Cheers



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Work logged] (LANG-1627) BooleanUtils.xor not behaving as expected with any odd number of true's

2022-05-11 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1627?focusedWorklogId=768957&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-768957
 ]

ASF GitHub Bot logged work on LANG-1627:


Author: ASF GitHub Bot
Created on: 11/May/22 09:57
Start Date: 11/May/22 09:57
Worklog Time Spent: 10m 
  Work Description: stevebosman-oc commented on PR #891:
URL: https://github.com/apache/commons-lang/pull/891#issuecomment-1123477214

   Cancelling this PR - merged into PR 890




Issue Time Tracking
---

Worklog Id: (was: 768957)
Time Spent: 50m  (was: 40m)

> BooleanUtils.xor not behaving as expected with any odd number of true's
> ---
>
> Key: LANG-1627
> URL: https://issues.apache.org/jira/browse/LANG-1627
> Project: Commons Lang
>  Issue Type: Bug
>Affects Versions: 3.11
>Reporter: Alberto Scotto
>Priority: Major
>  Time Spent: 50m
>  Remaining Estimate: 0h
>
> Hi,
> I was expecting a xor function that takes a variable number of arguments to 
> *return true if and only if exactly one among all of the arguments is true*, 
> regardless of the number of arguments.
> This holds true given three false's:
> {code:java}
> @Test
> public void threeFalse() {
>  boolean[] bools = new boolean[]{Boolean.FALSE, Boolean.FALSE, Boolean.FALSE};
>  assertFalse(BooleanUtils.xor(bools));
> }{code}
>  
>  It also holds true given 4 true's, as well as for any even number of trues.
> {code:java}
> @Test
> public void fourTrue() {
> boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, 
> Boolean.TRUE, Boolean.TRUE};
> assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> The above tests pass.
> But with any odd number of true's that doesn't hold anymore:
>  
> {code:java}
> @Test
> public void threeTrue() {
>  boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, Boolean.TRUE};
>  assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> This test fails.
> That was totally unexpected to me.
>  But as it turns out, even
> {noformat}
> true ^ true ^ true{noformat}
> evaluates to true. That was unexpected too to me, at a first sight.
> The thing is that xor (I mean the original boolean operator) is a binary 
> operator, so if you want to make it n-ary, one simple solution is to apply it 
> in two by two: ((a ^ b) ^ c) ^ d
>  And that's what is done in the implementation of the method BooleanUtils#xor.
> But that brings to BooleanUtils.xor(true, true, true) == true, and at the 
> same time BooleanUtils.xor(true, true, true, true) == false, which just 
> doesn't sound right to me.
> Whether or not you agree with me that that is a bug of the method, please at 
> least update the Javadoc, because right now it is not providing the user 
> enough information. Look:
> {code:java}
> Performs an xor on a set of booleans.
>  BooleanUtils.xor(true, true)   = false
>  BooleanUtils.xor(false, false) = false
>  BooleanUtils.xor(true, false)  = true
> {code}
>  
> Thanks.
> Cheers



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Work logged] (LANG-1627) BooleanUtils.xor not behaving as expected with any odd number of true's

2022-05-11 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1627?focusedWorklogId=768908&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-768908
 ]

ASF GitHub Bot logged work on LANG-1627:


Author: ASF GitHub Bot
Created on: 11/May/22 08:55
Start Date: 11/May/22 08:55
Worklog Time Spent: 10m 
  Work Description: stevebosman-oc commented on PR #891:
URL: https://github.com/apache/commons-lang/pull/891#issuecomment-1123388323

   I've been asked to merge this with another pull request, but the last build 
failed. I'm just getting this in order before doing the merge




Issue Time Tracking
---

Worklog Id: (was: 768908)
Time Spent: 40m  (was: 0.5h)

> BooleanUtils.xor not behaving as expected with any odd number of true's
> ---
>
> Key: LANG-1627
> URL: https://issues.apache.org/jira/browse/LANG-1627
> Project: Commons Lang
>  Issue Type: Bug
>Affects Versions: 3.11
>Reporter: Alberto Scotto
>Priority: Major
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> Hi,
> I was expecting a xor function that takes a variable number of arguments to 
> *return true if and only if exactly one among all of the arguments is true*, 
> regardless of the number of arguments.
> This holds true given three false's:
> {code:java}
> @Test
> public void threeFalse() {
>  boolean[] bools = new boolean[]{Boolean.FALSE, Boolean.FALSE, Boolean.FALSE};
>  assertFalse(BooleanUtils.xor(bools));
> }{code}
>  
>  It also holds true given 4 true's, as well as for any even number of trues.
> {code:java}
> @Test
> public void fourTrue() {
> boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, 
> Boolean.TRUE, Boolean.TRUE};
> assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> The above tests pass.
> But with any odd number of true's that doesn't hold anymore:
>  
> {code:java}
> @Test
> public void threeTrue() {
>  boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, Boolean.TRUE};
>  assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> This test fails.
> That was totally unexpected to me.
>  But as it turns out, even
> {noformat}
> true ^ true ^ true{noformat}
> evaluates to true. That was unexpected too to me, at a first sight.
> The thing is that xor (I mean the original boolean operator) is a binary 
> operator, so if you want to make it n-ary, one simple solution is to apply it 
> in two by two: ((a ^ b) ^ c) ^ d
>  And that's what is done in the implementation of the method BooleanUtils#xor.
> But that brings to BooleanUtils.xor(true, true, true) == true, and at the 
> same time BooleanUtils.xor(true, true, true, true) == false, which just 
> doesn't sound right to me.
> Whether or not you agree with me that that is a bug of the method, please at 
> least update the Javadoc, because right now it is not providing the user 
> enough information. Look:
> {code:java}
> Performs an xor on a set of booleans.
>  BooleanUtils.xor(true, true)   = false
>  BooleanUtils.xor(false, false) = false
>  BooleanUtils.xor(true, false)  = true
> {code}
>  
> Thanks.
> Cheers



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Work logged] (LANG-1627) BooleanUtils.xor not behaving as expected with any odd number of true's

2022-05-11 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1627?focusedWorklogId=768903&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-768903
 ]

ASF GitHub Bot logged work on LANG-1627:


Author: ASF GitHub Bot
Created on: 11/May/22 08:42
Start Date: 11/May/22 08:42
Worklog Time Spent: 10m 
  Work Description: kinow commented on PR #890:
URL: https://github.com/apache/commons-lang/pull/890#issuecomment-1123372654

   > Hi, I'm happy to merge them. It was purely because they seemed to two 
distinct things. One improving the existing javadoc, and one adding additional 
functionality.
   
   Thanks, that's definitely good to try to split into separate pull requests 
when there are multiple tasks within an issue, but I think it should be fine to 
include the documentation/Javadoc clarification in the same PR. They can be 
squashed as a single commit too :+1:




Issue Time Tracking
---

Worklog Id: (was: 768903)
Time Spent: 0.5h  (was: 20m)

> BooleanUtils.xor not behaving as expected with any odd number of true's
> ---
>
> Key: LANG-1627
> URL: https://issues.apache.org/jira/browse/LANG-1627
> Project: Commons Lang
>  Issue Type: Bug
>Affects Versions: 3.11
>Reporter: Alberto Scotto
>Priority: Major
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Hi,
> I was expecting a xor function that takes a variable number of arguments to 
> *return true if and only if exactly one among all of the arguments is true*, 
> regardless of the number of arguments.
> This holds true given three false's:
> {code:java}
> @Test
> public void threeFalse() {
>  boolean[] bools = new boolean[]{Boolean.FALSE, Boolean.FALSE, Boolean.FALSE};
>  assertFalse(BooleanUtils.xor(bools));
> }{code}
>  
>  It also holds true given 4 true's, as well as for any even number of trues.
> {code:java}
> @Test
> public void fourTrue() {
> boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, 
> Boolean.TRUE, Boolean.TRUE};
> assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> The above tests pass.
> But with any odd number of true's that doesn't hold anymore:
>  
> {code:java}
> @Test
> public void threeTrue() {
>  boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, Boolean.TRUE};
>  assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> This test fails.
> That was totally unexpected to me.
>  But as it turns out, even
> {noformat}
> true ^ true ^ true{noformat}
> evaluates to true. That was unexpected too to me, at a first sight.
> The thing is that xor (I mean the original boolean operator) is a binary 
> operator, so if you want to make it n-ary, one simple solution is to apply it 
> in two by two: ((a ^ b) ^ c) ^ d
>  And that's what is done in the implementation of the method BooleanUtils#xor.
> But that brings to BooleanUtils.xor(true, true, true) == true, and at the 
> same time BooleanUtils.xor(true, true, true, true) == false, which just 
> doesn't sound right to me.
> Whether or not you agree with me that that is a bug of the method, please at 
> least update the Javadoc, because right now it is not providing the user 
> enough information. Look:
> {code:java}
> Performs an xor on a set of booleans.
>  BooleanUtils.xor(true, true)   = false
>  BooleanUtils.xor(false, false) = false
>  BooleanUtils.xor(true, false)  = true
> {code}
>  
> Thanks.
> Cheers



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Work logged] (LANG-1627) BooleanUtils.xor not behaving as expected with any odd number of true's

2022-05-11 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1627?focusedWorklogId=768896&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-768896
 ]

ASF GitHub Bot logged work on LANG-1627:


Author: ASF GitHub Bot
Created on: 11/May/22 08:34
Start Date: 11/May/22 08:34
Worklog Time Spent: 10m 
  Work Description: stevebosman-oc commented on PR #890:
URL: https://github.com/apache/commons-lang/pull/890#issuecomment-1123353796

   Hi, I'm happy to merge them. It was purely because they seemed to two 
distinct things. One improving the existing javadoc, and one adding additional 
functionality.




Issue Time Tracking
---

Worklog Id: (was: 768896)
Time Spent: 20m  (was: 10m)

> BooleanUtils.xor not behaving as expected with any odd number of true's
> ---
>
> Key: LANG-1627
> URL: https://issues.apache.org/jira/browse/LANG-1627
> Project: Commons Lang
>  Issue Type: Bug
>Affects Versions: 3.11
>Reporter: Alberto Scotto
>Priority: Major
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> Hi,
> I was expecting a xor function that takes a variable number of arguments to 
> *return true if and only if exactly one among all of the arguments is true*, 
> regardless of the number of arguments.
> This holds true given three false's:
> {code:java}
> @Test
> public void threeFalse() {
>  boolean[] bools = new boolean[]{Boolean.FALSE, Boolean.FALSE, Boolean.FALSE};
>  assertFalse(BooleanUtils.xor(bools));
> }{code}
>  
>  It also holds true given 4 true's, as well as for any even number of trues.
> {code:java}
> @Test
> public void fourTrue() {
> boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, 
> Boolean.TRUE, Boolean.TRUE};
> assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> The above tests pass.
> But with any odd number of true's that doesn't hold anymore:
>  
> {code:java}
> @Test
> public void threeTrue() {
>  boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, Boolean.TRUE};
>  assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> This test fails.
> That was totally unexpected to me.
>  But as it turns out, even
> {noformat}
> true ^ true ^ true{noformat}
> evaluates to true. That was unexpected too to me, at a first sight.
> The thing is that xor (I mean the original boolean operator) is a binary 
> operator, so if you want to make it n-ary, one simple solution is to apply it 
> in two by two: ((a ^ b) ^ c) ^ d
>  And that's what is done in the implementation of the method BooleanUtils#xor.
> But that brings to BooleanUtils.xor(true, true, true) == true, and at the 
> same time BooleanUtils.xor(true, true, true, true) == false, which just 
> doesn't sound right to me.
> Whether or not you agree with me that that is a bug of the method, please at 
> least update the Javadoc, because right now it is not providing the user 
> enough information. Look:
> {code:java}
> Performs an xor on a set of booleans.
>  BooleanUtils.xor(true, true)   = false
>  BooleanUtils.xor(false, false) = false
>  BooleanUtils.xor(true, false)  = true
> {code}
>  
> Thanks.
> Cheers



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Work logged] (LANG-1627) BooleanUtils.xor not behaving as expected with any odd number of true's

2022-05-04 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1627?focusedWorklogId=766105&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-766105
 ]

ASF GitHub Bot logged work on LANG-1627:


Author: ASF GitHub Bot
Created on: 04/May/22 15:40
Start Date: 04/May/22 15:40
Worklog Time Spent: 10m 
  Work Description: stevebosman-oc opened a new pull request, #891:
URL: https://github.com/apache/commons-lang/pull/891

   The name one-hot seems appropriate - https://en.wikipedia.org/wiki/One-hot




Issue Time Tracking
---

Worklog Id: (was: 766105)
Remaining Estimate: 0h
Time Spent: 10m

> BooleanUtils.xor not behaving as expected with any odd number of true's
> ---
>
> Key: LANG-1627
> URL: https://issues.apache.org/jira/browse/LANG-1627
> Project: Commons Lang
>  Issue Type: Bug
>Affects Versions: 3.11
>Reporter: Alberto Scotto
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> Hi,
> I was expecting a xor function that takes a variable number of arguments to 
> *return true if and only if exactly one among all of the arguments is true*, 
> regardless of the number of arguments.
> This holds true given three false's:
> {code:java}
> @Test
> public void threeFalse() {
>  boolean[] bools = new boolean[]{Boolean.FALSE, Boolean.FALSE, Boolean.FALSE};
>  assertFalse(BooleanUtils.xor(bools));
> }{code}
>  
>  It also holds true given 4 true's, as well as for any even number of trues.
> {code:java}
> @Test
> public void fourTrue() {
> boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, 
> Boolean.TRUE, Boolean.TRUE};
> assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> The above tests pass.
> But with any odd number of true's that doesn't hold anymore:
>  
> {code:java}
> @Test
> public void threeTrue() {
>  boolean[] bools = new boolean[]{Boolean.TRUE, Boolean.TRUE, Boolean.TRUE};
>  assertFalse(BooleanUtils.xor(bools));
> }
> {code}
> This test fails.
> That was totally unexpected to me.
>  But as it turns out, even
> {noformat}
> true ^ true ^ true{noformat}
> evaluates to true. That was unexpected too to me, at a first sight.
> The thing is that xor (I mean the original boolean operator) is a binary 
> operator, so if you want to make it n-ary, one simple solution is to apply it 
> in two by two: ((a ^ b) ^ c) ^ d
>  And that's what is done in the implementation of the method BooleanUtils#xor.
> But that brings to BooleanUtils.xor(true, true, true) == true, and at the 
> same time BooleanUtils.xor(true, true, true, true) == false, which just 
> doesn't sound right to me.
> Whether or not you agree with me that that is a bug of the method, please at 
> least update the Javadoc, because right now it is not providing the user 
> enough information. Look:
> {code:java}
> Performs an xor on a set of booleans.
>  BooleanUtils.xor(true, true)   = false
>  BooleanUtils.xor(false, false) = false
>  BooleanUtils.xor(true, false)  = true
> {code}
>  
> Thanks.
> Cheers



--
This message was sent by Atlassian Jira
(v8.20.7#820007)