You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Bob Wiegand (JIRA)" <ji...@apache.org> on 2011/06/06 15:55:59 UTC
[jira] [Created] (AMQCPP-375)
decaf::lang::Long::to{Hex,Binary,Octal}String problems
decaf::lang::Long::to{Hex,Binary,Octal}String problems
------------------------------------------------------
Key: AMQCPP-375
URL: https://issues.apache.org/jira/browse/AMQCPP-375
Project: ActiveMQ C++ Client
Issue Type: Bug
Components: Decaf
Affects Versions: 3.3.0
Reporter: Bob Wiegand
Assignee: Timothy Bish
Priority: Trivial
decaf::lang::Long::to{Hex,Binary,Octal}String return the wrong result for numbers less than -2^32 (on platforms with 64 bit long long): the returned string only represents the low 32 bits.
A separate problem causes decaf::lang::{Integer,Long}::toOctalString to return the wrong result for negative numbers because there are not an even multiple of 3 bits.
This test program demonstrates the problems
$ cat test.cpp
#include <iostream>
#include <decaf/lang/Integer.h>
#include <decaf/lang/Long.h>
using namespace std;
using namespace decaf::lang;
void testLong (long long value)
{
cout << "testLong(" << dec << value << "LL)\n"
<< "\ndec:\t" << dec << value << "\ntoB10:\t" << Long::toString(value, 10)
<< "\nhex:\t" << hex << value << "\ntoHex:\t" << Long::toHexString(value)
<< "\noct:\t" << oct << value << "\ntoOct:\t" << Long::toOctalString(value)
<< "\noct:\t" << oct << value << "\ntoB8:\t" << Long::toString(value, 8)
<< "\nhex:\t" << hex << value << "\ntoBin:\t" << Long::toBinaryString(value)
<< "\n\n";
}
void testInteger (int value)
{
cout << "testInteger(" << dec << value << ")\n"
<< "\ndec:\t" << dec << value << "\ntoB10:\t" << Integer::toString(value, 10)
<< "\nhex:\t" << hex << value << "\ntoHex:\t" << Integer::toHexString(value)
<< "\noct:\t" << oct << value << "\ntoOct:\t" << Integer::toOctalString(value)
<< "\noct:\t" << oct << value << "\ntoB8:\t" << Integer::toString(value, 8)
<< "\nhex:\t" << hex << value << "\ntoBin:\t" << Integer::toBinaryString(value)
<< "\n\n";
}
int main (int argc, char **argv)
{
testLong(-1LL);
testLong(-0xFF00000000LL);
testInteger(-1);
testInteger(0xDFFF0000);
return 0;
}
$
$ ./a.out
testLong(-1LL)
dec: -1
toB10: -1
hex: ffffffffffffffff
toHex: ffffffff
oct: 1777777777777777777777
toOct: 77777777777
oct: 1777777777777777777777
toB8: -1
hex: ffffffffffffffff
toBin: 11111111111111111111111111111111
testLong(-1095216660480LL)
dec: -1095216660480
toB10: -1095216660480
hex: ffffff0100000000
toHex: 00000000
oct: 1777777760040000000000
toOct: 40000000000
oct: 1777777760040000000000
toB8: -17740000000000
hex: ffffff0100000000
toBin: 00000000000000000000000000000000
testInteger(-1)
dec: -1
toB10: -1
hex: ffffffff
toHex: ffffffff
oct: 37777777777
toOct: 77777777777
oct: 37777777777
toB8: -1
hex: ffffffff
toBin: 11111111111111111111111111111111
testInteger(-536936448)
dec: -536936448
toB10: -536936448
hex: dfff0000
toHex: dfff0000
oct: 33777600000
toOct: 73777600000
oct: 33777600000
toB8: -4000200000
hex: dfff0000
toBin: 11011111111111110000000000000000
$
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (AMQCPP-375)
decaf::lang::Long::to{Hex,Binary,Octal}String problems
Posted by "Timothy Bish (Resolved) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AMQCPP-375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Timothy Bish resolved AMQCPP-375.
---------------------------------
Resolution: Fixed
Fix Version/s: 3.5.0
Patch applied, no test provided so YMMV.
> decaf::lang::Long::to{Hex,Binary,Octal}String problems
> ------------------------------------------------------
>
> Key: AMQCPP-375
> URL: https://issues.apache.org/jira/browse/AMQCPP-375
> Project: ActiveMQ C++ Client
> Issue Type: Bug
> Components: Decaf
> Affects Versions: 3.3.0
> Reporter: Bob Wiegand
> Assignee: Timothy Bish
> Priority: Trivial
> Fix For: 3.5.0
>
> Attachments: suggested.patch
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> decaf::lang::Long::to{Hex,Binary,Octal}String return the wrong result for numbers less than -2^32 (on platforms with 64 bit long long): the returned string only represents the low 32 bits.
> A separate problem causes decaf::lang::{Integer,Long}::toOctalString to return the wrong result for negative numbers because there are not an even multiple of 3 bits.
> This test program demonstrates the problems
> $ cat test.cpp
> #include <iostream>
> #include <decaf/lang/Integer.h>
> #include <decaf/lang/Long.h>
> using namespace std;
> using namespace decaf::lang;
> void testLong (long long value)
> {
> cout << "testLong(" << dec << value << "LL)\n"
> << "\ndec:\t" << dec << value << "\ntoB10:\t" << Long::toString(value, 10)
> << "\nhex:\t" << hex << value << "\ntoHex:\t" << Long::toHexString(value)
> << "\noct:\t" << oct << value << "\ntoOct:\t" << Long::toOctalString(value)
> << "\noct:\t" << oct << value << "\ntoB8:\t" << Long::toString(value, 8)
> << "\nhex:\t" << hex << value << "\ntoBin:\t" << Long::toBinaryString(value)
> << "\n\n";
> }
> void testInteger (int value)
> {
> cout << "testInteger(" << dec << value << ")\n"
> << "\ndec:\t" << dec << value << "\ntoB10:\t" << Integer::toString(value, 10)
> << "\nhex:\t" << hex << value << "\ntoHex:\t" << Integer::toHexString(value)
> << "\noct:\t" << oct << value << "\ntoOct:\t" << Integer::toOctalString(value)
> << "\noct:\t" << oct << value << "\ntoB8:\t" << Integer::toString(value, 8)
> << "\nhex:\t" << hex << value << "\ntoBin:\t" << Integer::toBinaryString(value)
> << "\n\n";
> }
> int main (int argc, char **argv)
> {
> testLong(-1LL);
> testLong(-0xFF00000000LL);
> testInteger(-1);
> testInteger(0xDFFF0000);
> return 0;
> }
> $
> $ ./a.out
> testLong(-1LL)
> dec: -1
> toB10: -1
> hex: ffffffffffffffff
> toHex: ffffffff
> oct: 1777777777777777777777
> toOct: 77777777777
> oct: 1777777777777777777777
> toB8: -1
> hex: ffffffffffffffff
> toBin: 11111111111111111111111111111111
> testLong(-1095216660480LL)
> dec: -1095216660480
> toB10: -1095216660480
> hex: ffffff0100000000
> toHex: 00000000
> oct: 1777777760040000000000
> toOct: 40000000000
> oct: 1777777760040000000000
> toB8: -17740000000000
> hex: ffffff0100000000
> toBin: 00000000000000000000000000000000
> testInteger(-1)
> dec: -1
> toB10: -1
> hex: ffffffff
> toHex: ffffffff
> oct: 37777777777
> toOct: 77777777777
> oct: 37777777777
> toB8: -1
> hex: ffffffff
> toBin: 11111111111111111111111111111111
> testInteger(-536936448)
> dec: -536936448
> toB10: -536936448
> hex: dfff0000
> toHex: dfff0000
> oct: 33777600000
> toOct: 73777600000
> oct: 33777600000
> toB8: -4000200000
> hex: dfff0000
> toBin: 11011111111111110000000000000000
> $
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (AMQCPP-375)
decaf::lang::Long::to{Hex,Binary,Octal}String problems
Posted by "Bob Wiegand (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AMQCPP-375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bob Wiegand updated AMQCPP-375:
-------------------------------
Attachment: suggested.patch
> decaf::lang::Long::to{Hex,Binary,Octal}String problems
> ------------------------------------------------------
>
> Key: AMQCPP-375
> URL: https://issues.apache.org/jira/browse/AMQCPP-375
> Project: ActiveMQ C++ Client
> Issue Type: Bug
> Components: Decaf
> Affects Versions: 3.3.0
> Reporter: Bob Wiegand
> Assignee: Timothy Bish
> Priority: Trivial
> Attachments: suggested.patch
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> decaf::lang::Long::to{Hex,Binary,Octal}String return the wrong result for numbers less than -2^32 (on platforms with 64 bit long long): the returned string only represents the low 32 bits.
> A separate problem causes decaf::lang::{Integer,Long}::toOctalString to return the wrong result for negative numbers because there are not an even multiple of 3 bits.
> This test program demonstrates the problems
> $ cat test.cpp
> #include <iostream>
> #include <decaf/lang/Integer.h>
> #include <decaf/lang/Long.h>
> using namespace std;
> using namespace decaf::lang;
> void testLong (long long value)
> {
> cout << "testLong(" << dec << value << "LL)\n"
> << "\ndec:\t" << dec << value << "\ntoB10:\t" << Long::toString(value, 10)
> << "\nhex:\t" << hex << value << "\ntoHex:\t" << Long::toHexString(value)
> << "\noct:\t" << oct << value << "\ntoOct:\t" << Long::toOctalString(value)
> << "\noct:\t" << oct << value << "\ntoB8:\t" << Long::toString(value, 8)
> << "\nhex:\t" << hex << value << "\ntoBin:\t" << Long::toBinaryString(value)
> << "\n\n";
> }
> void testInteger (int value)
> {
> cout << "testInteger(" << dec << value << ")\n"
> << "\ndec:\t" << dec << value << "\ntoB10:\t" << Integer::toString(value, 10)
> << "\nhex:\t" << hex << value << "\ntoHex:\t" << Integer::toHexString(value)
> << "\noct:\t" << oct << value << "\ntoOct:\t" << Integer::toOctalString(value)
> << "\noct:\t" << oct << value << "\ntoB8:\t" << Integer::toString(value, 8)
> << "\nhex:\t" << hex << value << "\ntoBin:\t" << Integer::toBinaryString(value)
> << "\n\n";
> }
> int main (int argc, char **argv)
> {
> testLong(-1LL);
> testLong(-0xFF00000000LL);
> testInteger(-1);
> testInteger(0xDFFF0000);
> return 0;
> }
> $
> $ ./a.out
> testLong(-1LL)
> dec: -1
> toB10: -1
> hex: ffffffffffffffff
> toHex: ffffffff
> oct: 1777777777777777777777
> toOct: 77777777777
> oct: 1777777777777777777777
> toB8: -1
> hex: ffffffffffffffff
> toBin: 11111111111111111111111111111111
> testLong(-1095216660480LL)
> dec: -1095216660480
> toB10: -1095216660480
> hex: ffffff0100000000
> toHex: 00000000
> oct: 1777777760040000000000
> toOct: 40000000000
> oct: 1777777760040000000000
> toB8: -17740000000000
> hex: ffffff0100000000
> toBin: 00000000000000000000000000000000
> testInteger(-1)
> dec: -1
> toB10: -1
> hex: ffffffff
> toHex: ffffffff
> oct: 37777777777
> toOct: 77777777777
> oct: 37777777777
> toB8: -1
> hex: ffffffff
> toBin: 11111111111111111111111111111111
> testInteger(-536936448)
> dec: -536936448
> toB10: -536936448
> hex: dfff0000
> toHex: dfff0000
> oct: 33777600000
> toOct: 73777600000
> oct: 33777600000
> toB8: -4000200000
> hex: dfff0000
> toBin: 11011111111111110000000000000000
> $
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (AMQCPP-375)
decaf::lang::Long::to{Hex,Binary,Octal}String problems
Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AMQCPP-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13045356#comment-13045356 ]
Timothy Bish commented on AMQCPP-375:
-------------------------------------
It would be great if you could add some new unit tests to go along with this to validate that this stays fixed long into the future.
> decaf::lang::Long::to{Hex,Binary,Octal}String problems
> ------------------------------------------------------
>
> Key: AMQCPP-375
> URL: https://issues.apache.org/jira/browse/AMQCPP-375
> Project: ActiveMQ C++ Client
> Issue Type: Bug
> Components: Decaf
> Affects Versions: 3.3.0
> Reporter: Bob Wiegand
> Assignee: Timothy Bish
> Priority: Trivial
> Attachments: suggested.patch
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> decaf::lang::Long::to{Hex,Binary,Octal}String return the wrong result for numbers less than -2^32 (on platforms with 64 bit long long): the returned string only represents the low 32 bits.
> A separate problem causes decaf::lang::{Integer,Long}::toOctalString to return the wrong result for negative numbers because there are not an even multiple of 3 bits.
> This test program demonstrates the problems
> $ cat test.cpp
> #include <iostream>
> #include <decaf/lang/Integer.h>
> #include <decaf/lang/Long.h>
> using namespace std;
> using namespace decaf::lang;
> void testLong (long long value)
> {
> cout << "testLong(" << dec << value << "LL)\n"
> << "\ndec:\t" << dec << value << "\ntoB10:\t" << Long::toString(value, 10)
> << "\nhex:\t" << hex << value << "\ntoHex:\t" << Long::toHexString(value)
> << "\noct:\t" << oct << value << "\ntoOct:\t" << Long::toOctalString(value)
> << "\noct:\t" << oct << value << "\ntoB8:\t" << Long::toString(value, 8)
> << "\nhex:\t" << hex << value << "\ntoBin:\t" << Long::toBinaryString(value)
> << "\n\n";
> }
> void testInteger (int value)
> {
> cout << "testInteger(" << dec << value << ")\n"
> << "\ndec:\t" << dec << value << "\ntoB10:\t" << Integer::toString(value, 10)
> << "\nhex:\t" << hex << value << "\ntoHex:\t" << Integer::toHexString(value)
> << "\noct:\t" << oct << value << "\ntoOct:\t" << Integer::toOctalString(value)
> << "\noct:\t" << oct << value << "\ntoB8:\t" << Integer::toString(value, 8)
> << "\nhex:\t" << hex << value << "\ntoBin:\t" << Integer::toBinaryString(value)
> << "\n\n";
> }
> int main (int argc, char **argv)
> {
> testLong(-1LL);
> testLong(-0xFF00000000LL);
> testInteger(-1);
> testInteger(0xDFFF0000);
> return 0;
> }
> $
> $ ./a.out
> testLong(-1LL)
> dec: -1
> toB10: -1
> hex: ffffffffffffffff
> toHex: ffffffff
> oct: 1777777777777777777777
> toOct: 77777777777
> oct: 1777777777777777777777
> toB8: -1
> hex: ffffffffffffffff
> toBin: 11111111111111111111111111111111
> testLong(-1095216660480LL)
> dec: -1095216660480
> toB10: -1095216660480
> hex: ffffff0100000000
> toHex: 00000000
> oct: 1777777760040000000000
> toOct: 40000000000
> oct: 1777777760040000000000
> toB8: -17740000000000
> hex: ffffff0100000000
> toBin: 00000000000000000000000000000000
> testInteger(-1)
> dec: -1
> toB10: -1
> hex: ffffffff
> toHex: ffffffff
> oct: 37777777777
> toOct: 77777777777
> oct: 37777777777
> toB8: -1
> hex: ffffffff
> toBin: 11111111111111111111111111111111
> testInteger(-536936448)
> dec: -536936448
> toB10: -536936448
> hex: dfff0000
> toHex: dfff0000
> oct: 33777600000
> toOct: 73777600000
> oct: 33777600000
> toB8: -4000200000
> hex: dfff0000
> toBin: 11011111111111110000000000000000
> $
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira