www.delorie.com/archives/browse.cgi | search |
Message-ID: | <330CEF04.189D@post.comstar.ru> |
Date: | Thu, 20 Feb 1997 16:40:36 -0800 |
From: | Dim Zegebart <zager AT post DOT comstar DOT ru> |
Reply-To: | zager AT post DOT comstar DOT ru |
Organization: | zager AT post DOT comstar DOT ru |
MIME-Version: | 1.0 |
To: | DJGPP Mail List <djgpp AT delorie DOT com> |
Subject: | Re: fixed point math: SOLUTION!!! |
References: | <5egfq4$3pk AT nr1 DOT toronto DOT istar DOT net> <5eh67b$m3i AT news DOT ox DOT ac DOT uk> |
George Foot wrote: > > #define subtract1(a,b) a-b /* very bad */ > #define subtract2(a,b) (a)-(b) /* better */ > #define subtract3(a,b) ((a)-(b)) /* best */ I read in GCC info (C Extensions chapter) what the best way to do such things is : #define substruct(a,b) ({int _a=a,_b=b,x;x=_a-_b;}) The value of whole expression will eq. to last statment, x - in our case. -- Regards, Dim Zegebart, Moscow Russia.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |