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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d2c23a44c4c8fd6b X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: fixed point types over an interface Date: 1997/02/07 Message-ID: #1/1 X-Deja-AN: 215247647 references: <32FBB550.41C67EA6@efogm.msd.ray.com> content-type: text/plain; charset=ISO-8859-1 organization: Estormza Software mime-version: 1.0 newsgroups: comp.lang.ada Date: 1997-02-07T00:00:00+00:00 List-Id: In article <32FBB550.41C67EA6@efogm.msd.ray.com>, Allen Krell wrote: >With Ada83, is it safe to assume that two different >compilers will store a fixed point type in the same way? No. The only requirment (in the absence of a specification of small) is that the actual delta be smaller (power of 2) less than what was specified in the type. If you are sending the data over an interface, it is Very Strongly Recommended that you specify Small for the type. Also, (I think) it's also true that a compiler is allowed to reject a specification of small that is not a power of 2, so you're better off only using that power (if you can). Note that that will also be more efficient. The syntax is type T is delta D range F .. L; for T'Small use D; This specifies the value of the LSB. >Two processors are communicating over an interface. The >applications for each processor are written/compiled >using compilers from two different vendors. A ripe environment for problems. > >If each application has > >type FX_PT_TYPE is delta .001 range -100 .. +100; >Variable : FX_PT_TYPE := 1.345; > >Will the binary representation of 'Variable' >be the same with both compilers? Not necessarily. You really should do this: F_Delta : constant := 0.001; type F is delta F_Delta range -100.0 .. 100.0; for F'Small use F_Delta; And while you're at it, put a size clause on there, too. for F'Size use 32; -- or whatever If possible, use a power of 2 as the delta, as it'll be more portable. F_Delta : constant := 1.0 / 1024; Send the data over the interface using a fixed point type with a power of 2 delta, and convert it to whatever "internal" type is appropriate (be it another fixed point type, or more likely some floating point type) when it's received. -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271