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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e7b0825eca61cc23 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!news2.euro.net!feeder1.cambrium.nl!feed.tweaknews.nl!npeer.de.kpn-eurorings.net!news.uni-stuttgart.de!not-for-mail From: Peter Hermann Newsgroups: comp.lang.ada Subject: Re: floating point to fixed point conversion Date: Wed, 22 Feb 2006 14:25:50 +0000 (UTC) Organization: Comp.Center (RUS), U of Stuttgart, FRG Message-ID: References: <1140560157.376760.292570@g43g2000cwa.googlegroups.com> X-Trace: infosun2.rus.uni-stuttgart.de 1140618350 28358 141.58.7.20 (22 Feb 2006 14:25:50 GMT) X-Complaints-To: news@news.uni-stuttgart.de NNTP-Posting-Date: Wed, 22 Feb 2006 14:25:50 +0000 (UTC) User-Agent: tin/1.7.8-20050315 ("Scalpay") (UNIX) (Linux/2.4.27 (i686)) Xref: g2news1.google.com comp.lang.ada:3070 Date: 2006-02-22T14:25:50+00:00 List-Id: 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