[
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