From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([69.77.167.62] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1KvHQ1-0007cu-3y for garchives@archives.gentoo.org; Wed, 29 Oct 2008 20:13:29 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5DFC7E03E2; Wed, 29 Oct 2008 20:13:28 +0000 (UTC) Received: from yw-out-1718.google.com (yw-out-1718.google.com [74.125.46.156]) by pigeon.gentoo.org (Postfix) with ESMTP id 3C5C1E03E2 for ; Wed, 29 Oct 2008 20:13:28 +0000 (UTC) Received: by yw-out-1718.google.com with SMTP id 5so70396ywm.46 for ; Wed, 29 Oct 2008 13:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=NOtGVpbMa9Drlgc2HRnpoWVxy//mUWG5tQzOMfb61rU=; b=Cm+KmeH4eAu58RaW5OGkSBHt30qlcTIDv+N4GBLrTxYL6jg5CIH6q7QhEtSB6lHoUk T0JtEalW9aFV2rY0vngE2cVqAyWUPYkCqPuhwKFo521ZjKU7GETDGbbNvwkkb8QC6FCs VB11AyuyP7fVxzEF4f6lRNyWprUgIxG73HO0U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=DfgIZcsnfoshep8nscVFxhFCt15tJJ5gNvNy6v+jcpxxVv19fK8VGdC0ptB7V074pY Dl3LpEgRc8lbM+WrN7ZjxScJHNymQmHnG3U9n8VebHGRDUdVR9HnOEQc8UPNADmzxnGz qTXj7MTx26ZK3183hTt45TOlTAE3SiQ+og8Cg= Received: by 10.90.80.19 with SMTP id d19mr7794569agb.76.1225311206689; Wed, 29 Oct 2008 13:13:26 -0700 (PDT) Received: by 10.90.81.1 with HTTP; Wed, 29 Oct 2008 13:13:26 -0700 (PDT) Message-ID: <38af3d670810291313p7937d68ei55d2b6ff9b9df6ad@mail.gmail.com> Date: Wed, 29 Oct 2008 18:13:26 -0200 From: "Jorge Peixoto de Morais Neto" Sender: jorgepeixotomorais@gmail.com To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] package.keywords syntax? In-Reply-To: <200810290916.29649.alan.mckinnon@gmail.com> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200810290041.39256.alan.mckinnon@gmail.com> <38af3d670810281555j43a2c0dfl990860eb9b85921b@mail.gmail.com> <200810290916.29649.alan.mckinnon@gmail.com> X-Google-Sender-Auth: 85476b83500bd69e X-Archives-Salt: 0a96aad0-07b3-4d90-8130-b5ab37677058 X-Archives-Hash: 2f24ab2ab4fd4708e413d1cec35ed468 >> >> I mean to really know C, >> >> that is, read a rigorous book such as "C: A Reference Manual" and be >> >> able to write portable programs with well-defined behavior. Speaking >> >> of well-defined behavior, do you know what happens when you cast a >> >> float to an int, and the float is too big to fit into the int? >> > >> > Did oyu try it yourself and see? >> >> The point is that the behavior in this situation is "undefined". It >> might do anything. Programming in C is different than programming in >> Python. > > Most likely the compiler will try to treat the float as an int and use the > first 4 bytes of the float, ignoring the rest. No, you misunderstood C. C, despite being lower level than (say) Java, does not view variables as typeless bit patterns. It views them as integers, real numbers, etc. So if you perform float real_number = 0.5; int integer = real_number; The value of "integer" will be 0; if C were to actually interpret the bit pattern of real_number as an integer, you would get 1056964608 (0x3f000000) - at least on my machine. That is not what C does, though. The real problem is when you type float real_number = 4e10; int integer = real_number; If your integer can only hold values up to 2^31 - 1 , the behavior of the above code is undefined. In a language like Python, everything either behaves as you intended, of throws an exception. This is why I say "In C, you must completely understand the behavior of every statement or function, and you *must* handle the possibility of errors". -- Software is like sex: it is better when it is free - Linus Torvalds