comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.acm.org>
Subject: Re: Looking For Simple Routine To Put Integer Into Float
Date: Mon, 24 May 2010 16:05:41 -0700
Date: 2010-05-24T16:05:41-07:00	[thread overview]
Message-ID: <htf0pb$c91$1@tornado.tornevall.net> (raw)
In-Reply-To: <570f8963-82ba-42b9-981f-0f92e59161b3@a2g2000prd.googlegroups.com>

ChristopherL wrote:
> 
> type Unknown_integer_type is range -(2**16) ..(2**16) -1; -- 32 Bit
> Integer

If you want an unconstrained, 32-bit, signed integer type, something from 
Interfaces (such as Integer_32) is usually the way to go.

> An_Unknown_Integer: Unknown_integer_type;
> An_Integer: Integer;
> A_Float: Float;            -- Hoping this float is usually 32 bits

Why hope? If you need a 32-bit floating-point type, again something from 
Interfaces might be in order, or declare an appropriate type for your application:

type Real is digits 6 [range Low .. High];
for Real'Size use 32;

In any case, the size of Float should be documented for your compiler.

> An_Integer := 1234;
> 
> An_Unknown_Integer := An_Integer;

This shouldn't compile, as An_Integer has a different type than 
An_Unknown_Integer; you need a type conversion.

> A_Float := Float (An_Unknown_Integer);

What is the point of Unknown_Integer_Type and An_Unknown_Integer? What's wrong with

A_Float := Float (An_Integer);

?

-- 
Jeff Carter
"You can never forget too much about C++."
115



  parent reply	other threads:[~2010-05-24 23:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <570f8963-82ba-42b9-981f-0f92e59161b3@a2g2000prd.googlegroups.com>
2010-05-24 22:53 ` Looking For Simple Routine To Put Integer Into Float Ludovic Brenta
2010-05-24 23:05 ` Jeffrey R. Carter [this message]
2010-05-25  2:47 ` Stephen Leake
2010-05-25 16:34   ` mockturtle
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox