Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: truncate 20 bits to 10 bits

Re: truncate 20 bits to 10 bits

From: Mladen Gogala <gogala_at_sbcglobal.net>
Date: Sun, 19 Feb 2006 03:49:46 GMT
Message-Id: <pan.2006.02.19.03.49.45.752599@sbcglobal.net>


On Sat, 18 Feb 2006 05:04:02 -0800, mmt1 wrote:

> Hi.
> I have a multiplier that multiplies 2 floating point numbers with 7
> bits exponent and 10 bits mantissa.so its output has 7 bits exponent
> and 20 bits mantissa.
> now its output must return to its input in order to compute another
> multiplication.on the other hand its output must be truncated to 10
> bits. how can I do this? please help me.
> thanks.

Dividing things by 1024 would be a way of doing it. That is equivalent to the right shift for 10 places. It looks something like this:

#include <stdio.h>
main ()
{
  int a = 1048576;
  int b = a >> 10;
  printf ("B is:%d\n", b);
  b = a / 1024;
  printf ("B is:%d\n", b);
}

$ gcc -O3 ttt.c -o ttt;./ttt
B is:1024
B is:1024

You chose a wrong newsgroup. Questions like this belong to MS SQL Server group or AutoCAD group, not an Oracle group.

-- 
http://www.mgogala.com
Received on Sat Feb 18 2006 - 21:49:46 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US