Browse Source

* fixed bug for val when processing -2147483648 and low(int64) (merged)

Jonas Maebe 25 years ago
parent
commit
0d5167e124
2 changed files with 10 additions and 18 deletions
  1. 5 9
      rtl/inc/int64.inc
  2. 5 9
      rtl/inc/sstrings.inc

+ 5 - 9
rtl/inc/int64.inc

@@ -392,13 +392,6 @@
     Code:=InitVal(s,negative,base);
     Code:=InitVal(s,negative,base);
     if Code>length(s) then
     if Code>length(s) then
      exit;
      exit;
-    if negative and (s='-9223372036854775808') then
-     begin
-       Code:=0;
-       ValInt64:=Int64($80000000) shl 32;
-       exit;
-     end;
-
     { high(int64) produces 0 in version 1.0 (JM) }
     { high(int64) produces 0 in version 1.0 (JM) }
     with qwordrec(maxint64) do
     with qwordrec(maxint64) do
       begin
       begin
@@ -424,7 +417,7 @@
        Temp:=Temp*Int64(base);
        Temp:=Temp*Int64(base);
      If (u >= base) or
      If (u >= base) or
         ((base = 10) and
         ((base = 10) and
-         (maxint64-temp < u)) or
+         (maxint64-temp+ord(negative) < u)) or
         ((base <> 10) and
         ((base <> 10) and
          (qword(maxqword-temp) < u)) or
          (qword(maxqword-temp) < u)) or
         (prev > maxqword div qword(base)) Then
         (prev > maxqword div qword(base)) Then
@@ -486,7 +479,10 @@
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2000-07-28 12:29:49  jonas
+  Revision 1.4  2000-11-17 17:01:23  jonas
+    * fixed bug for val when processing -2147483648 and low(int64) (merged)
+
+  Revision 1.3  2000/07/28 12:29:49  jonas
     * fixed web bug1069
     * fixed web bug1069
     * fixed similar (and other) problems in val() for int64 and qword
     * fixed similar (and other) problems in val() for int64 and qword
       (both merged from fixes branch)
       (both merged from fixes branch)

+ 5 - 9
rtl/inc/sstrings.inc

@@ -359,13 +359,6 @@ begin
   Code:=InitVal(s,negative,base);
   Code:=InitVal(s,negative,base);
   if Code>length(s) then
   if Code>length(s) then
    exit;
    exit;
-  if negative and (s='-2147483648') then
-   begin
-     Code:=0;
-     ValSignedInt:=$80000000;
-     exit;
-   end;
-
   while Code<=Length(s) do
   while Code<=Length(s) do
    begin
    begin
      case s[Code] of
      case s[Code] of
@@ -379,7 +372,7 @@ begin
      Temp := Temp*ValUInt(base);
      Temp := Temp*ValUInt(base);
      If (u >= base) or
      If (u >= base) or
         ((base = 10) and
         ((base = 10) and
-         (MaxSIntValue-temp < u)) or
+         (MaxSIntValue-temp+ord(negative) < u)) or
         ((base <> 10) and
         ((base <> 10) and
          (ValUInt(MaxUIntValue-Temp) < u)) or
          (ValUInt(MaxUIntValue-Temp) < u)) or
         (prev > ValUInt(MaxUIntValue) div ValUInt(Base)) Then
         (prev > ValUInt(MaxUIntValue) div ValUInt(Base)) Then
@@ -560,7 +553,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2000-11-06 20:34:24  peter
+  Revision 1.6  2000-11-17 17:01:23  jonas
+    * fixed bug for val when processing -2147483648 and low(int64) (merged)
+
+  Revision 1.5  2000/11/06 20:34:24  peter
     * changed ver1_0 defines to temporary defs
     * changed ver1_0 defines to temporary defs
 
 
   Revision 1.4  2000/10/21 18:20:17  florian
   Revision 1.4  2000/10/21 18:20:17  florian