}
nbytes = size * descr->itemsize;
/* Check for overflow */
- if (nbytes / descr->itemsize != size) {
+ if (nbytes / descr->itemsize != (size_t)size) {
return PyErr_NoMemory();
}
op = PyMem_NEW(arrayobject, 1);
return NULL;
}
if (self->ob_size > 0) {
- if (fwrite(self->ob_item, self->ob_descr->itemsize,
+ if ((int)fwrite(self->ob_item, self->ob_descr->itemsize,
self->ob_size, fp) != self->ob_size) {
PyErr_SetFromErrno(PyExc_IOError);
clearerr(fp);
{
unsigned char buf[4];
- buf[0] = (val >> 24);
- buf[1] = (val >> 16);
- buf[2] = (val >> 8);
- buf[3] = (val >> 0);
+ buf[0] = (unsigned char) (val >> 24);
+ buf[1] = (unsigned char) (val >> 16);
+ buf[2] = (unsigned char) (val >> 8);
+ buf[3] = (unsigned char) (val >> 0);
return fwrite(buf, 4, 1, outf);
}
tablen = ysize * zsize * sizeof(long);
starttab = (long *)malloc(tablen);
lengthtab = (long *)malloc(tablen);
- rlebuflen = 1.05 * xsize +10;
+ rlebuflen = (int) (1.05 * xsize +10);
rledat = (unsigned char *)malloc(rlebuflen);
if (!starttab || !lengthtab || !rledat) {
PyErr_NoMemory();
starttab = (long *)malloc(tablen);
lengthtab = (long *)malloc(tablen);
- rlebuflen = 1.05 * xsize + 10;
+ rlebuflen = (int) (1.05 * xsize + 10);
rlebuf = (unsigned char *)malloc(rlebuflen);
lumbuf = (unsigned char *)malloc(xsize * sizeof(long));
if (!starttab || !lengthtab || !rlebuf || !lumbuf) {
iptr -= 8;
count = (iptr - sptr) / 4;
while (count) {
- todo = count > 126 ? 126 : count;
+ todo = count > 126 ? 126 : (short)count;
count -= todo;
*optr++ = 0x80 | todo;
while (todo > 8) {
iptr += 4;
count = (iptr - sptr) / 4;
while (count) {
- todo = count > 126 ? 126 : count;
+ todo = count > 126 ? 126 : (short)count;
count -= todo;
- *optr++ = todo;
- *optr++ = cc;
+ *optr++ = (unsigned char) todo;
+ *optr++ = (unsigned char) cc;
}
}
*optr++ = 0;
}
/* Return the next random number in the range [0.0 .. 1.0) */
-static float
+static double
r_random(r)
Rotorobj *r;
{
int x, y, z;
- float val, term;
+ double val, term;
x = r->seed[0];
y = r->seed[1];
r->seed[1] = y;
r->seed[2] = z;
- term = (float)(
- (((float)x)/(float)30269.0) +
- (((float)y)/(float)30307.0) +
- (((float)z)/(float)30323.0)
+ term = (double)(
+ (((double)x)/(double)30269.0) +
+ (((double)y)/(double)30307.0) +
+ (((double)z)/(double)30323.0)
);
- val = term - (float)floor((double)term);
+ val = term - (double)floor((double)term);
if (val >= 1.0)
val = 0.0;
Rotorobj *r;
short s;
{
- return (short)((short)(r_random(r) * (float)s) % s);
+ return (short)((short)(r_random(r) * (double)s) % s);
}
static void
RTR_e_rotors(r);
RTR_d_rotors(r);
for (i = 0; i < r->rotors; i++) {
- r->positions[i] = r_rand(r,r->size);
+ r->positions[i] = (unsigned char) r_rand(r,r->size);
r->advances[i] = (1+(2*(r_rand(r,r->size/2))));
RTR_permute_rotor(r,
&(r->e_rotor[(i*r->size)]),
p += incr;
/* Second byte */
- *p = ((e&1)<<7) | (fbits>>16);
+ *p = (char) (((e&1)<<7) | (fbits>>16));
p += incr;
/* Third byte */
p += incr;
/* Second byte */
- *p = ((e&0xF)<<4) | (fhi>>24);
+ *p = (char) (((e&0xF)<<4) | (fhi>>24));
p += incr;
/* Third byte */
long x;
if (get_long(v, &x) < 0)
return -1;
- *p = x;
+ *p = (char)x;
return 0;
}
long x;
if (get_long(v, &x) < 0)
return -1;
- * (short *)p = x;
+ * (short *)p = (short)x;
return 0;
}
return -1;
i = f->size;
do {
- p[--i] = x;
+ p[--i] = (char)x;
x >>= 8;
} while (i > 0);
return 0;
return -1;
i = f->size;
do {
- p[--i] = x;
+ p[--i] = (char)x;
x >>= 8;
} while (i > 0);
return 0;
return -1;
i = f->size;
do {
- *p++ = x;
+ *p++ = (char)x;
x >>= 8;
} while (--i > 0);
return 0;
return -1;
i = f->size;
do {
- *p++ = x;
+ *p++ = (char)x;
x >>= 8;
} while (--i > 0);
return 0;
#endif /* macintosh */
#ifndef __STDC__
+#ifndef MS_WINDOWS
extern char *strerror PROTO((int));
#endif
+#endif
/* Last exception stored by err_setval() */