From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 24 06:51:52 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 24E9B16A4CE for ; Tue, 24 Feb 2004 06:51:52 -0800 (PST) Received: from artis.latnet.lv (artis.latnet.lv [159.148.107.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 95B3E43D1F for ; Tue, 24 Feb 2004 06:51:49 -0800 (PST) (envelope-from ac-lists@latnet.lv) Received: from artis.latnet.lv (localhost [127.0.0.1]) by artis.latnet.lv (Postfix) with ESMTP id 368AAC0CF for ; Tue, 24 Feb 2004 16:51:48 +0200 (EET) To: freebsd-hackers@freebsd.org From: Artis Caune Organization: Latnet Content-Type: text/plain; format=flowed; charset=utf-8 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Tue, 24 Feb 2004 16:51:47 +0200 Message-ID: User-Agent: Opera7.23/FreeBSD M2 build 518 Subject: type casts in KLD X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Feb 2004 14:51:52 -0000 Hi! I'm writting kld module, and have some weird problems with mixing types and casts. e.x. "if (long + u_long + u_long < 0)" don't work, but "if (long < 0 - u_long - u_long)" works fine! and code like this: "cur_rate = min_rate + \ (((max_rate - min_rate) * \ (cur_level / level / 100))) / 100)" where: cur_rate, min_rate, max_rate - u_long; cur_level, level - u_quad_t ; I cast-ed expresion: "cur_rate = min_rate + \ (((max_rate - min_rate) * \ ((u_long) cur_level / (u_quad_t) level / 100))) / (u_long) 100)" and it seems to be ok! Someone can point me to article, url where I can find more about complex arithmetic operations with different types and how to proper use different types in "if" statements? -- Artis