www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/11/27/03:10:50

To: Kimberley Burchett <OKRA AT max DOT tiac DOT net>
Cc: DJGPP Mailing List <djgpp AT sun DOT soe DOT clarkson DOT edu>
Subject: Re: -1441992/4 = 1073381326
Date: Sun, 27 Nov 94 08:28:39 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>

> int main() {
> 
>   long x = -1441992;
>   unsigned y = 4;
> 
>   printf("%d / %d = %d\n",x,y,x/y);
> }
> 
>   Spits this out:
>
> -1441992 / 4 = 1073381326

Seems like it does the division as unsigned one.  I don't know if this
should be so (seems sick at the first glance), but the remedy is at least
simple: just cast that 4 to int or long.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019