[Commits] Rev 4126: Merge in file:///home/psergey/dev2/10.0-cp/

Sergey Petrunya psergey at askmonty.org
Thu Mar 27 12:57:54 EET 2014


At file:///home/psergey/dev2/10.0-cp/

------------------------------------------------------------
revno: 4126 [merge]
revision-id: psergey at askmonty.org-20140327105753-wi4yda5l5itv18n0
parent: sergii at pisem.net-20140327102527-l0bf04kjdt8dy50u
parent: psergey at askmonty.org-20140327105529-8ogxytk3nnt30b1e
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: 10.0-cp
timestamp: Thu 2014-03-27 14:57:53 +0400
message:
  Merge
modified:
  sql/field.cc                   sp1f-field.cc-19700101030959-f4imaofclsea3n4fj4ow5m7havmyxa2r
=== modified file 'sql/field.cc'
--- a/sql/field.cc	2014-03-26 21:25:38 +0000
+++ b/sql/field.cc	2014-03-27 10:55:29 +0000
@@ -1175,6 +1175,15 @@ inline ulonglong char_prefix_to_ulonglon
   return uint8korr(src); 
 }
 
+/*
+  Compute res = a - b, without losing precision and taking care that these are
+  unsigned numbers.
+*/
+static inline double safe_substract(ulonglong a, ulonglong b)
+{
+  return (a > b)? double(a - b) : -double(b - a);
+}
+
 
 /**
   @brief
@@ -1227,10 +1236,10 @@ double Field::pos_in_interval_val_str(Fi
   minp= char_prefix_to_ulonglong(minp_prefix);
   maxp= char_prefix_to_ulonglong(maxp_prefix);
   double n, d;
-  n= mp - minp;
+  n= safe_substract(mp, minp);
   if (n < 0)
     return 0.0;
-  d= maxp - minp;
+  d= safe_substract(maxp, minp);
   if (d <= 0)
     return 1.0;
   return MY_MIN(n/d, 1.0);



More information about the commits mailing list