comp.lang.ada
 help / color / mirror / Atom feed
From: Peter Hermann <ica2ph@csv.ica.uni-stuttgart.de>
Subject: Re: floating point to fixed point conversion
Date: Wed, 22 Feb 2006 14:25:50 +0000 (UTC)
Date: 2006-02-22T14:25:50+00:00	[thread overview]
Message-ID: <dths9e$rm6$1@infosun2.rus.uni-stuttgart.de> (raw)
In-Reply-To: 1140560157.376760.292570@g43g2000cwa.googlegroups.com

riya1012@gmail.com wrote:
> hello guys,
> 
> I need some help from you. I am doing a DSP project and for that I need
> to do some C coding for the conversion of sample data which is in
> floating point representation to fixed point representation.
> the sample data is in floating point like
> 0.224128
> 2.299965
> 0.448350
> -1.779926
> My DSP algorithm is implemented in C and is supposed to be using fixed
> point representation.
> The above data is intended to be converted to fixed integer format.I
> request you to help me out regarding this conversion.I will be very
> glad if u give me some hints or algorithms for this conversion.
> 

with ada.text_io,ada.integer_text_io,system;
procedure fixed_riya is
  type data is delta 0.000_001 range -9.9 .. 9.9;
  for data'size use 32;
  feld : constant array(positive range <>) of data :=(
  0.224128,  2.299965,  0.448350,  -1.779926, 1.0, 1.5);

  fel2 : array(feld'range) of integer;
  for fel2'address use feld'address;
begin
ada.text_io.put_line("starting program fixed_riya");

for x in fel2'range loop
  ada.integer_text_io.put(fel2(x),base=>10);
  ada.integer_text_io.put(fel2(x),base=>2,width=>32);
  ada.text_io.put_line(data'image(feld(x)));
end loop;
--starting program fixed_riya
--     235015           2#111001011000000111# 0.224128
--    2411688       2#1001001100110010101000# 2.299965
--     470129          2#1110010110001110001# 0.448350
--   -1866387       -2#111000111101010010011#-1.779925
--    1048576        2#100000000000000000000# 1.000000
--    1572864        2#110000000000000000000# 1.500000

--ada.integer_text_io.put(data'aft); -- giving 6

end fixed_riya;  --20060222ph

-- 
--Peter.Hermann@ihr.uni-stuttgart.de                (+49)0711-685-87244
--Nobelstr.19 Raum 0.030, D-70569 Stuttgart IHR Hoechstleistungsrechnen
--http://www.ihr.uni-stuttgart.de/                   Fax  0711-89238279




      parent reply	other threads:[~2006-02-22 14:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-21 22:15 floating point to fixed point conversion riya1012
2006-02-21 23:49 ` Jeffrey R. Carter
2006-02-21 23:51 ` Keith Thompson
2006-02-22  0:51   ` Keith Thompson
2006-02-22 11:01 ` stuart clark
2006-02-22 14:25 ` Peter Hermann [this message]
replies disabled

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