From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ac625b61af767c90 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-03-02 02:58:10 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: patkwee@web.de (Pat) Newsgroups: comp.lang.ada Subject: Re: Color components and fixed point numbers Date: 2 Mar 2004 02:58:09 -0800 Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 149.157.1.122 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1078225089 4973 127.0.0.1 (2 Mar 2004 10:58:09 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 2 Mar 2004 10:58:09 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:6005 Date: 2004-03-02T02:58:09-08:00 List-Id: Thank you very much for your answer. > First fix your type declarations ... Besides, you also omitted the semicolons. Sorry, was just too lazy... > Second, you got the numbers wrong, or you want something that many > compilers would not support as a value for 'Small, even with a rep > clause. You should use: I'm very new to Ada, so what is rep clause? > Since that is how the hardware works, that should be what you expect. So > Small_RGB'(1.0,1.0,1.0) and Wide_RGB'(1.0,1.0,1.0) are different colors. > Or better stated: Small_RGB(255.0/256, 255.0/256. 255.0/256) is not > equal to Wide_RGB(65535.0/65536, 65535.0/65536, 65535.0/65536), and you > should not expect them to be equal. Yes, this is the reason why I used 255 and 65535 as denominator. I am not a expert on color conversion or representation, but I think 0.0 should represent the darkest and 1.0 the brigthest color independent from the representation as integers. So 255 and 65535 should be the same brightness. If I would use integer arithmetic I would do it like this: type Small_Comp is range 0 .. 255; type Wide_Comp is range 0 .. 65535; -- Small_Comp'Last and Wide_Comp'Last should represent the same brightest color -- Small_COmp'First and Wide_Comp'Last should represent the same darkest color w : Wide_Comp; s : Small_Comp:=?; w := s*65535 / 255; -- equals w:=s*257 s := w / 257; I though the reason why 1.0/255 is not working may be that there is no exact floating point representation of 1.0/255 and so due to rounding 255 * (1.0/255) < 1.0 . > Can you force an implementation to make the two brightest whites equal? > It is not too difficult. Most compilers will give the expected result > for: > > type Small_Component is delta 1.0/256 range 1.0/256 .. 1.0; > type Wide_Component is delta 1.0/65536 range 1.0/65536 .. 1.0; I think this will only move my problem, so that now the darkest colors are not identical. Thank you very much, Pat