Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* C code to convert DEC floating pt to IEEE floating pt
@ 1994-08-29 22:14 Mark M Mehl
  1994-08-30 13:31 ` o\bBob Schaefer
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Mark M Mehl @ 1994-08-29 22:14 UTC (permalink / raw)



We're interested in some C code to convert DEC floating pt (VAX & PDP)
to IEEE floating point format (PCes).

I've ran across a solution in Ada on the DECUS (FLOTFLOT.ADA;1)
for doing this.  I also ran across a partial solution in Fortran
([DECUS]AAAREADME.92A_VAX;2) for doing some of this.  I also know
about the 1991 VAX Professional article.

I would rather not convert these solutions to C if someone has
already done so.  :-)  Please direct me to some C sources.

I've looked on gatekeeper.dec.com for some of this code, but I've
been unable to figure out which files--if any--would have this.

Thanks for your help.
-- 
 /\ Mark M Mehl, alias Superticker (Supertickler to some)
<><> Internet: mehl@IAstate.edu
 \/ Preferred UUCP: uunet!iastate.edu!mehl
Disclaimer: You got to be kidding; who would want to claim anything I said?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: C code to convert DEC floating pt to IEEE floating pt
  1994-08-29 22:14 C code to convert DEC floating pt to IEEE floating pt Mark M Mehl
@ 1994-08-30 13:31 ` o\bBob Schaefer
  1994-08-30 13:43 ` Bob Koehler
  1994-08-31  7:13 ` Hennie van Niekerk
  2 siblings, 0 replies; 6+ messages in thread
From: o\bBob Schaefer @ 1994-08-30 13:31 UTC (permalink / raw)


In article <mehl.778198445@biner3.ameslab.gov>,
Mark M Mehl <mehl@iastate.edu> wrote:
>
>We're interested in some C code to convert DEC floating pt (VAX & PDP)
>to IEEE floating point format (PCes).
>

Mark,
  I believe the following two routines are what you are looking for.  They
go from IEEE to VAX and VAX to IEEE.

ieeetodec(float *ieee_val, float *dec_val))
{
	register unsigned long dec_result;
	register unsigned long ieee;

	ieee = *((unsigned long *)ieee_val);
	dec_result = (ieee >> 16) | (ieee << 16);
	dec_result += 0x00000100;

	*((unsigned long *)dec_val) = dec_result;
}

dectoieee(float *dec_val, float *ieee_val)
{
	register unsigned long dec;
	register unsigned long ieee_result;

	dec = *((unsigned long *) dec_val);
	ieee_result = (dec >> 16) | (dec << 16);
	ieee_result -= 0x01000000;

	*((unsigned long *)ieee_val) = ieee_result;
}

hope this helped you out.  I'm not sure if this will get you right to a PC
or not, its from a document about a Motorola controller.

Bob Schaefer
Bob.Schaefer@launchpad.unc.edu



-- 
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Launchpad is an experimental internet BBS. The views of its users do not 
necessarily represent those of UNC-Chapel Hill, OIT, or the SysOps.
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: C code to convert DEC floating pt to IEEE floating pt
  1994-08-29 22:14 C code to convert DEC floating pt to IEEE floating pt Mark M Mehl
  1994-08-30 13:31 ` o\bBob Schaefer
@ 1994-08-30 13:43 ` Bob Koehler
  1994-08-31  7:13 ` Hennie van Niekerk
  2 siblings, 0 replies; 6+ messages in thread
From: Bob Koehler @ 1994-08-30 13:43 UTC (permalink / raw)


In article <mehl.778198445@biner3.ameslab.gov>, mehl@iastate.edu (Mark M Mehl) writes...
> 
>We're interested in some C code to convert DEC floating pt (VAX & PDP)
>to IEEE floating point format (PCes).
> 
[...]
> 
>I would rather not convert these solutions to C if someone has
>already done so.  :-)  Please direct me to some C sources.
> 

Does it really have to be source?  VMS has this capability built in.  Look at
CVT$CONVERT_FLOAT in the back of the LIB$ manual, you can call this from any
language.

------------------------------------------------------------------------------
Bob Koehler                     | 
rkoehler@author.gsfc.nasa.gov   | koehler@plane.gsfc.nasa.gov (Mon - Fri only)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: C code to convert DEC floating pt to IEEE floating pt
  1994-08-29 22:14 C code to convert DEC floating pt to IEEE floating pt Mark M Mehl
  1994-08-30 13:31 ` o\bBob Schaefer
  1994-08-30 13:43 ` Bob Koehler
@ 1994-08-31  7:13 ` Hennie van Niekerk
  1994-09-01 22:52   ` Mark M Mehl
  1994-09-07 15:46   ` Realtime Data Aquisition Software Joe Stam
  2 siblings, 2 replies; 6+ messages in thread
From: Hennie van Niekerk @ 1994-08-31  7:13 UTC (permalink / raw)


>We're interested in some C code to convert DEC floating pt (VAX & PDP)
>to IEEE floating point format (PCes).

>I would rather not convert these solutions to C if someone has
>already done so.  :-)  Please direct me to some C sources.


Here's some code I use to convert floats generated on a PDP 11/23 to IEEE 
format.

This was written for a 32 bit compiler on the PC.  There is a problem with 
passing the argument as *float. It seems to me that sometimes the compiler's 
run-time checking causes problems (NaN's etc.)  Rather change the routine to 
something like    float vax2pcfloat( unsigned *vax )   .  I have done this 
somewhere, but can't find the code at this moment.

/*------------------------------------------------------------------- * 
vax2pcFloat() * Convert VAX format float*2 to IEEE format float*2 
*-------------------------------------------------------------------*/
void vax2pcFloat( float *vax ){
	union	{
		struct	{
			unsigned ivalue;
		} ints;
		float fvalue;
	} pcFloat;
	union	{
		struct	{
			unsigned short int1,int2;
		} ints;
		unsigned lInt;
	} slInt;
	unsigned char sign;
	short exponent;
	unsigned mantissa;
	unsigned short indx;

	pcFloat.fvalue = *vax;
	slInt.lInt = pcFloat.ints.ivalue;
	indx = slInt.ints.int1;
	slInt.ints.int1 = slInt.ints.int2;
	slInt.ints.int2 = indx;
	pcFloat.ints.ivalue = slInt.lInt;
	sign = pcFloat.ints.ivalue >> 31;
	exponent = ((pcFloat.ints.ivalue & 0x7F800000uL) >> 23);
	mantissa = pcFloat.ints.ivalue & 0x7FFFFFuL;
	if( exponent ) pcFloat.fvalue = 1.; else pcFloat.fvalue = 0.;
	for( indx=0; indx < 23; indx++ )
		if( mantissa & ( 1uL << indx ) )
			pcFloat.fvalue += pow(2., (double)(indx - 23.));
	pcFloat.fvalue = pcFloat.fvalue * pow(2., (double)(exponent-129.));
	if( sign ) pcFloat.fvalue = -pcFloat.fvalue;
	*vax = pcFloat.fvalue;
}
/*-------------------------------------------------------------------

Hope this helps
Hennie



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: C code to convert DEC floating pt to IEEE floating pt
  1994-08-31  7:13 ` Hennie van Niekerk
@ 1994-09-01 22:52   ` Mark M Mehl
  1994-09-07 15:46   ` Realtime Data Aquisition Software Joe Stam
  1 sibling, 0 replies; 6+ messages in thread
From: Mark M Mehl @ 1994-09-01 22:52 UTC (permalink / raw)



In <vnie-hj.4.2E642D83@mella.ee.up.ac.za> vnie-hj@mella.ee.up.ac.za (Hennie van Niekerk) writes:
>>We're interested in some C code to convert DEC floating pt (VAX & PDP)
>>to IEEE floating point format (PCes).

Thanks for everyone's solutions.  I've just finished saving them.
BTW, most of the numbers are begin generated on TSX/PDP-11 and then
converted to IEEE on the PC (via C code written for LabView).
(We're converting some of our PDP-11 application code to LabView.)
As a result, the VMS library solution won't work for most of our
cases.  Everything is in single precision float.

>/*------------------------------------------------------------------- * 
>vax2pcFloat() * Convert VAX format float*2 to IEEE format float*2 
>*-------------------------------------------------------------------*/

I'm a little confused by the float*2 terminology above.  It looks
from the code below that everything is in 32-bit (single) float
rather than 64-bit "double float".  I guess I just don't understand
the "float*2" terminology.

|void vax2pcFloat( float *vax ){
|	union	{
|		struct	{
|			unsigned ivalue;
|		} ints;
|		float fvalue;
|	} pcFloat;
|	union	{
|		struct	{
|			unsigned short int1,int2;
|		} ints;
|		unsigned lInt;
|	} slInt;
|	unsigned char sign;
|	short exponent;
|	unsigned mantissa;
|	unsigned short indx;

|	pcFloat.fvalue = *vax;
|	slInt.lInt = pcFloat.ints.ivalue;
|	indx = slInt.ints.int1;
|	slInt.ints.int1 = slInt.ints.int2;
|	slInt.ints.int2 = indx;
|	pcFloat.ints.ivalue = slInt.lInt;
|	sign = pcFloat.ints.ivalue >> 31;
|	exponent = ((pcFloat.ints.ivalue & 0x7F800000uL) >> 23);
|	mantissa = pcFloat.ints.ivalue & 0x7FFFFFuL;
|	if( exponent ) pcFloat.fvalue = 1.; else pcFloat.fvalue = 0.;
|	for( indx=0; indx < 23; indx++ )
|		if( mantissa & ( 1uL << indx ) )
|			pcFloat.fvalue += pow(2., (double)(indx - 23.));
|	pcFloat.fvalue = pcFloat.fvalue * pow(2., (double)(exponent-129.));
|	if( sign ) pcFloat.fvalue = -pcFloat.fvalue;
|	*vax = pcFloat.fvalue;
|}

Thanks again for the help.  --Mark
-- 
 /\ Mark M Mehl, alias Superticker (Supertickler to some)
<><> Internet: mehl@IAstate.edu
 \/ Preferred UUCP: uunet!iastate.edu!mehl
Disclaimer: You got to be kidding; who would want to claim anything I said?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Realtime Data Aquisition Software
  1994-08-31  7:13 ` Hennie van Niekerk
  1994-09-01 22:52   ` Mark M Mehl
@ 1994-09-07 15:46   ` Joe Stam
  1 sibling, 0 replies; 6+ messages in thread
From: Joe Stam @ 1994-09-07 15:46 UTC (permalink / raw)



I am looking for a software package that will allow me to use a realtime vax, in conjuntion with a entire cluster, as a data aquisiton device.  We currently have all the hardware necessary and can write simple programs to store data aquired by a data aquisition board.  I am looking for a software package that will do this for several channels and display the data graphically, like a digitial oscilliscope.  Several packages exist for PC's to do this and we are using them now.  As our needs increase, however


, we would really like to use our VAX's.  If anyone is familiar with anything that can help me please let me know.

Thanks,
Joe Stam        stam@cs.hope.edu





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1994-09-07 15:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-08-29 22:14 C code to convert DEC floating pt to IEEE floating pt Mark M Mehl
1994-08-30 13:31 ` o\bBob Schaefer
1994-08-30 13:43 ` Bob Koehler
1994-08-31  7:13 ` Hennie van Niekerk
1994-09-01 22:52   ` Mark M Mehl
1994-09-07 15:46   ` Realtime Data Aquisition Software Joe Stam

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