ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl5-porters
perl5-porters
Re: New results with numconvert.t (UTS)
by Hal Morris other posts by this author
Jun 30 2001 6:28PM messages near this date
Re: lib/File/Find/taint.t | [PATCH] op/numconver.t
>  
>  On Sat, Jun 30, 2001 at 10:42:32AM -0700, Hal Morris wrote:
>  > You didn't explicitly ask for it, but here it is.
>  > Thanks,  Hal Morris,  UTS Global, LLC
>  
>  Thanks
>  > # '0' ne '4294967296',	4294967295	=> P n + P vs P + P
>  > # ok, as string ++ of max_uv is "4294967296", numeric is 0
>  
>  Aargh. Why didn't I notice that before?
>  
>  I take it that you don't see
>  
>  $ perl -e '$a=shift; $a++; printf "%u\n", $a' 4294967295
>  4294967295
>  

Actually, I DO get 4294967295
>  
>  Could you try the following test program (in the perl build directory)
>  and send the results.
>  
>  #include "EXTERN.h"
>  #include "perl.h"
>  int main (void) {
>    char buffer[256];
>    sprintf (buffer, "UV_MAX_P1='"STRINGIFY(UV_MAX_P1)"'\n%.32g",UV_MAX_P1);
>    puts(buffer);
>    sprintf (buffer, "IV_MAX_P1='"STRINGIFY(IV_MAX_P1)"'\n%.32g",IV_MAX_P1);
>    puts(buffer);
>    sprintf (buffer, "UV_MAX_P1_HALF='"STRINGIFY(UV_MAX_P1_HALF)"'\n%.32g",
>            UV_MAX_P1_HALF);
>    puts(buffer);
>    return 0;
>  }

juno>  ./nicks-test
UV_MAX_P1='(4.0 * (1 + ((((unsigned long)4294967295u)) > > 2)))'
4294967296
IV_MAX_P1='(2.0 * (1 + (((UV)((long)2147483647)) > > 1)))'
2147483648
UV_MAX_P1_HALF='(2.0 * (1 + ((((unsigned long)4294967295u)) > > 2)))'
2147483648
juno>  
>  
>  Could you try the not-quite-one-liner:
>  
>  perl -e 'foreach (0..3,28..34,62..64) {print "$_\t", ~0 >> $_; {use integer; print "\t", ~
0 > > $_, "\n"}}'
>  
>  for which I get
>  
>  0       4294967295      -1
>  1       2147483647      -1
>  2       1073741823      -1
>  3       536870911       -1
>  28      15      -1
>  29      7       -1
>  30      3       -1
>  31      1       -1
>  32      0       -1
>  33      0       -1
>  34      0       -1
>  62      0       -1
>  63      0       -1
>  64      0       -1

juno>  sh ni*2.sh                           
0       4294967295      -1
1       2147483647      -1
2       1073741823      -1
3       536870911       -1
28      15      -1
29      7       -1
30      3       -1
31      1       -1
32      0       -1
33      0       -1
34      0       -1
62      0       -1
63      0       -1
64      4294967295      -1
>  
>  here.
>  I'm curious if you get output that looks like this:
>  
>  0       4294967295    -1
>  1       4294967295    -1
>  2       4294967295    -1
>  3       4294967295    -1
>  
>  if you do (and maybe even if you don't) could you try the following patch
>  to see if it changes anything:
>  
>  --- perl.h.orig Thu Jun 28 16:17:15 2001
>  +++ perl.h      Sat Jun 30 17:40:25 2001
>  @@ -2165,17 +2165,17 @@
>      May find that some broken compiler will want the value cast to I32.
>      [after the shift, as signed >> may not be as secure as unsigned >>]
>   */
>  -#define I32_MAX_P1 (2.0 * (1 + (((U32)I32_MAX) >> 1)))
>  -#define U32_MAX_P1 (4.0 * (1 + ((U32_MAX) >> 2)))
>  +#define I32_MAX_P1 (2.0 * (1 + (((U32)I32_MAX) / 2)))
>  +#define U32_MAX_P1 (4.0 * (1 + ((U32_MAX) / 4)))
>   /* For compilers that can't correctly cast NVs over 0x7FFFFFFF (or
>      0x7FFFFFFFFFFFFFFF) to an unsigned integer. In the future, sizeof(UV)
>      may be greater than sizeof(IV), so don't assume that half max UV is max IV.
>   */
>  -#define U32_MAX_P1_HALF (2.0 * (1 + ((U32_MAX) >> 2)))
>  +#define U32_MAX_P1_HALF (2.0 * (1 + ((U32_MAX) / 4)))
>   
>  -#define UV_MAX_P1 (4.0 * (1 + ((UV_MAX) >> 2)))
>  -#define IV_MAX_P1 (2.0 * (1 + (((UV)IV_MAX) >> 1)))
>  -#define UV_MAX_P1_HALF (2.0 * (1 + ((UV_MAX) >> 2)))
>  +#define UV_MAX_P1 (4.0 * (1 + ((UV_MAX) / 4)))
>  +#define IV_MAX_P1 (2.0 * (1 + (((UV)IV_MAX) / 2)))
>  +#define UV_MAX_P1_HALF (2.0 * (1 + ((UV_MAX) / 4)))
>   
>   /* This may look like unnecessary jumping through hoops, but converting
>      out of range floating point values to integers *is* undefined behaviour,
>  
>  Thanks,
>  
>  UTS isn't like a Cray in any way is it?
>  
>  Nicholas Clark
>  

I'll let you know how this turns out shortly.

UTS is basically a SysVr4.2 UNIX on IBM 370/390 architecture.  I don't
know anything about Cray's O.S., but if you're talking about the basic
Cray architecture, as I knew it 10-15 years ago, I don't think they're
similar.  It does not, at any rate, have 36-bit words.

Thanks for your help.

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved