| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2003-01-02 17:27 UTC] jcoby at listingbook dot com
  [2003-01-03 10:28 UTC] jcoby at listingbook dot com
  [2003-01-13 16:49 UTC] iliaa@php.net
  [2003-01-13 17:19 UTC] jcoby at listingbook dot com
  [2003-01-13 17:21 UTC] sniper@php.net
  | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 06:00:01 2025 UTC | 
Large NUMERIC (20,0) fields can easily overflow the built-in php datatypes (float, real), causing truncation to 2147483647 (2^31 - 1). Some solutions: 1) Return numerics as string 2) Return numerics as gmp val 3) redesign my database Until (2) becomes a builtin datatype in PHP, I don't see this as a good solution. (3) is out of the question, so I elected to use (1); patch follows. I also have the CS_NUMERIC_TYPE ident as "numeric". --- php_sybase_ct.c.old Thu Jan 2 11:42:57 2003 +++ php_sybase_ct.c Thu Jan 2 11:46:18 2003 @@ -1166,9 +1166,9 @@ break; case CS_NUMERIC_TYPE: case CS_DECIMAL_TYPE: - result->datafmt[i].maxlength = result->datafmt[i].precision + 3; - /* numeric(10) vs numeric(10, 1) */ - result->numerics[i] = (result->datafmt[i].scale == 0) ? 1 : 2; + /* numerics can overflow real and long types, return as a string */ + result->datafmt[i].maxlength++; + result->numerics[i] = 0; break; default: result->datafmt[i].maxlength++; @@ -1769,10 +1769,12 @@ break; case CS_REAL_TYPE: case CS_FLOAT_TYPE: - case CS_NUMERIC_TYPE: case CS_DECIMAL_TYPE: return "real"; break; + case CS_NUMERIC_TYPE: + return "numeric"; + break; case CS_MONEY_TYPE: case CS_MONEY4_TYPE: return "money";