← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba

 

Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/pjl-misc into lp:zorba.

Commit message:
Better float-to-int-overflow checking -- fixes two FOTS tests.
Better string-to-integer conversion exception catching -- fixes 3 FOTS tests.

Requested reviews:
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/164054

Better float-to-int-overflow checking -- fixes two FOTS tests.
Better string-to-integer conversion exception catching -- fixes 3 FOTS tests.
-- 
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/164054
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/zorbatypes/integer.cpp'
--- src/zorbatypes/integer.cpp	2013-05-15 23:22:01 +0000
+++ src/zorbatypes/integer.cpp	2013-05-16 00:19:26 +0000
@@ -56,12 +56,13 @@
 #ifndef ZORBA_WITH_BIG_INTEGER
 template<class T>
 typename IntegerImpl<T>::value_type IntegerImpl<T>::ftoi( double d ) {
-  value_type const v( d >= 0 ? floor( d ) : ceil( d ) );
-  if ( v < 0 && d > 0 )
+  d = d >= 0 ? floor( d ) : ceil( d );
+  value_type const i = d;
+  if ( i != d )
     throw range_error(
       BUILD_STRING( '"', d, "\": value too large for integer" )
     );
-  return v;
+  return i;
 }
 #endif /* ZORBA_WITH_BIG_INTEGER */
 


Follow ups