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,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b257fba0affa289 X-Google-Attributes: gid103376,public From: Nick Roberts Subject: Re: fixed type (delta) in ada Date: 1999/11/28 Message-ID: <384118EF.911A1ABB@callnetuk.com>#1/1 X-Deja-AN: 554028512 Content-Transfer-Encoding: 7bit References: <383f6dbb.22609744@news.tstonramp.com> X-Original-NNTP-Posting-Host: da132d167.dialup.callnetuk.com X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: 28 Nov 1999 12:01:21 GMT, da132d167.dialup.callnetuk.com Organization: Computer Consultant MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-11-28T00:00:00+00:00 List-Id: Nap wrote: > > does anyone know why mutiplication between fixed type in ada produce a > big round off error? > ... Do you want the short answer or the long answer, Nap? The short version of the long answer is: the 'small' chosen for the type 'money' will be a power of two (e.g. 1/128); 0.20 will therefore not have an exact representation when converted to the type 'money'; this inexact representation of 0.20 will therefore produce an inexact result after multiplication. The short version of the short answer is: use a decimal type instead of a fixed type (example follows). type Money is delta 0.01 digits 11; Problem solved. -- Nick Roberts http://www.adapower.com/lab/adaos Always call for the professionals. (If they don't help, call for me ;-)