zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #15830
[Merge] lp:~paul-lucas/zorba/bug-1075106 into lp:zorba
Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/bug-1075106 into lp:zorba.
Commit message:
Fixed sign extension.
Requested reviews:
Zorba Coders (zorba-coders)
Related bugs:
Bug #1075106 in Zorba: "big unsignedInts doesn't work on 32bit"
https://bugs.launchpad.net/zorba/+bug/1075106
For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/bug-1075106/+merge/133612
Fixed sign extension.
--
https://code.launchpad.net/~paul-lucas/zorba/bug-1075106/+merge/133612
Your team Zorba Coders is requested to review the proposed merge of lp:~paul-lucas/zorba/bug-1075106 into lp:zorba.
=== modified file 'src/zorbatypes/integer.cpp'
--- src/zorbatypes/integer.cpp 2012-09-19 21:16:15 +0000
+++ src/zorbatypes/integer.cpp 2012-11-09 03:22:22 +0000
@@ -77,6 +77,14 @@
value_ = ztd::itoa( n, buf );
}
+#if ZORBA_SIZEOF_INT == ZORBA_SIZEOF_LONG
+TEMPLATE_DECL(T)
+INTEGER_IMPL(T)::IntegerImpl( unsigned int n ) {
+ ztd::itoa_buf_type buf;
+ value_ = ztd::itoa( n, buf );
+}
+#endif /* ZORBA_SIZEOF_INT == ZORBA_SIZEOF_LONG */
+
IntegerImpl::IntegerImpl( unsigned long n ) {
ztd::itoa_buf_type buf;
value_ = ztd::itoa( n, buf );
=== modified file 'src/zorbatypes/integer.h'
--- src/zorbatypes/integer.h 2012-10-30 21:26:12 +0000
+++ src/zorbatypes/integer.h 2012-11-09 03:22:22 +0000
@@ -578,23 +578,31 @@
TEMPLATE_DECL(I)
inline INTEGER_IMPL(I)::IntegerImpl( unsigned char c ) :
- value_( static_cast<long>( c ) )
+ value_( static_cast<long>( (unsigned long)c ) )
{
}
TEMPLATE_DECL(I)
inline INTEGER_IMPL(I)::IntegerImpl( unsigned short n ) :
- value_( static_cast<long>( n ) )
+ value_( static_cast<long>( (unsigned long)n ) )
{
}
+#ifdef ZORBA_WITH_BIG_INTEGER
+#if ZORBA_SIZEOF_INT != ZORBA_SIZEOF_LONG
+TEMPLATE_DECL(T)
+inline INTEGER_IMPL(T)::IntegerImpl( unsigned int n ) :
+ value_( static_cast<long>( (unsigned long)n ) )
+{
+}
+#endif /* ZORBA_SIZEOF_INT == ZORBA_SIZEOF_LONG */
+#else /* ZORBA_WITH_BIG_INTEGER */
TEMPLATE_DECL(I)
inline INTEGER_IMPL(I)::IntegerImpl( unsigned int n ) :
- value_( static_cast<long>( n ) )
+ value_( static_cast<value_type>( n ) )
{
}
-#ifndef ZORBA_WITH_BIG_INTEGER
TEMPLATE_DECL(I)
inline INTEGER_IMPL(I)::IntegerImpl( unsigned long n ) :
value_( static_cast<value_type>( n ) )
Follow ups