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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.166.199 with SMTP id zi7mr3866124pab.30.1392396443239; Fri, 14 Feb 2014 08:47:23 -0800 (PST) X-Received: by 10.50.122.10 with SMTP id lo10mr69843igb.11.1392396443098; Fri, 14 Feb 2014 08:47:23 -0800 (PST) Path: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!c10no22125100igq.0!news-out.google.com!h8ni8igy.0!nntp.google.com!c10no22125094igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 14 Feb 2014 08:47:22 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: <19ac8735-7a9c-429f-a111-a1b3c4b0985b@googlegroups.com> <3872de7d-2df4-4ddb-8348-45eb03b3588e@googlegroups.com> <6aca36a4-cd78-4098-a1f7-646cb37cd14d@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <55497f04-98ab-472e-b82d-bbab9dd6915e@googlegroups.com> Subject: Re: Differences between Ada 83 and other revisions From: adambeneschan@gmail.com Injection-Date: Fri, 14 Feb 2014 16:47:23 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Original-Bytes: 4945 Xref: number.nntp.dca.giganews.com comp.lang.ada:184865 Date: 2014-02-14T08:47:22-08:00 List-Id: On Friday, February 14, 2014 5:18:22 AM UTC-8, yoursurr...@gmail.com wrote: >=20 > One more question. Can you custom specify floats with a specific number = of decimal spaces? For example, if you want ada to handle decimals that yo= ur comp hardware cannot handle. I'm not sure just what you're looking for. Although you can define a float= ing-point type using a "digits" clause that could, in theory, give you grea= ter precision than your floating-point hardware can handle, in practice I d= on't think this is possible. That is, if your machine supports 32-bit and = 64-bit IEEE floats, then any floating-point type you define will map to one= of those two floats, or will produce an error message at compile time. A = compiler vendor *could* provide additional floating-point types that have t= o be emulated in software, but the language does not require them to do so,= and I don't know of any compiler that does. [On machines with no floating= -point, there is often a C library to emulate it, provided either by the ma= nufacturer or by some other third party; here again, though, Ada compiler v= endors are not required to go beyond that.] When you refer to "decimals", some people have assumed you were talking abo= ut "decimal fixed-point". This is a different kind of numeric type, genera= lly with a fixed number of digits after the decimal point. For example, th= is example from the RM defines a type that could be used for currency: type Money is delta 0.01 digits 15; "delta 0.01" means that every numeric value of the type is a multiple of 0.= 01; thus, this type defines numbers with two digits after the decimal point= . "digits 15" means that the type can handle numbers of up to 15 digits, c= ounting the digits after the decimal point; thus, the type can hold numbers= from about -(10**13-1) to 10**13-1. Those numbers are generally represent= ed as integers, but the compiler keeps track of the scale factor. So the n= umber 2.35 would be represented internally as the integer 235. If you mult= iply two such numbers, the program will multiply the integers and then auto= matically do any scaling and rounding for you. [By the way, it's legal to = declare a "delta 10.0" or "delta 100.0" type, etc., so that the scale facto= r is 10**N instead of 10**(-N).] Here again, though, compilers aren't required to support decimal fixed type= s that would involve an integer too big for it to handle. (If the Informat= ion Systems Annex is supported, then the compiler has to handle decimal fix= ed types that require 64-bit integers, but nothing larger.) There's no lan= guage-defined equivalent of Java's BigInteger or BigDecimal, for example, w= ith unlimited numbers of digits; on the other hand, compiler implementation= s could provide them if the vendor chooses. Also, it would be incorrect to= refer to types like this as "floats", since they're treated basically like= integers and don't fit into the traditional definition of "floating-point"= . So in any case, I think the answer to your question about numbers that the = hardware can't handle is: no, Ada compilers are not required to support suc= h numbers. However, they're not prevented from doing so. (And if hardware= has no floating-point at all, I think Ada may require the compiler to prov= ide *some* kind of software-emulated floating-point, although I'm not certa= in.) -- Adam