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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7dac35d19d7d0d84,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-14 07:03:10 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!71102-cm.able.ES!not-for-mail From: Jano <402450@cepsz.unizar.es> Newsgroups: comp.lang.ada Subject: Getting modular type size in bits Date: Fri, 14 Mar 2003 16:03:07 +0100 Message-ID: NNTP-Posting-Host: 71102-cm.able.es (212.97.171.102) X-Trace: fu-berlin.de 1047654189 69023730 212.97.171.102 (16 [49872]) X-Newsreader: MicroPlanet Gravity v2.50 Xref: archiver1.google.com comp.lang.ada:35320 Date: 2003-03-14T16:03:07+01:00 List-Id: Hello, maybe I'm overlooking something really silly: I have a generic function, for example: generic type Number is Mod <>; function Do(X: Number) return Number; I need to perform operations based on the logical type size, i.e. if the type is type Number is Mod 2**32; I want to know that the type size is 5. I'm aware of the 'modulus attribute, and 'size. If I understand correctly, 'size returns the size allocated by the compiler for the type (normally 8 in this case), not the _minimum_ size to allocate it (which is what I would need in that case). I can think of performing a log2 op, or some iterative proc to find it, but I would know if there is some ultra-efficient method (because the compiler has to know, I suppose, that size), because that function could be potentially called many times in loops. If I were using a generic package, I could perform that calculus in elaboration time, but is a generic function and I'd like to maintain it like that if possible. Other possibility but I can't think a mean of doing it would be a static expression who evaluates to that value, place it in the declarative part of the function, and hope that it will not be re-evaluated in each call... I don't know if it works that way. I'm getting off course? Can you point me in the right direction? Many thanks, -- ------------------------- Jano 402450[at]cepsz.unizar.es -------------------------