Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Duncan Murdoch <dmurdoch@pa...>  20031109 12:52:06

On Sun, 9 Nov 2003 00:41:48 0500 (EST), you wrote: >Use a union to hold bothe the float and the binary representation of >the float: > >float transmute(unsinged int mantissa) > float f; > union { > float f; > unsigned int i; > } fi; > > fi.i = mantissa; /* Mantissa is a value in the lower 23 bits , a > fraction where 0x007ffff is 1 ulp less than one. */ > fi.i = 0x3f800000; /* set exponent and sign bits */ > f = fi.f; /* interpret fi.i as binary representaiton of a float */ > return(f); >} That looks wrong. The mantissa should be normalized, with the most significant bit (always 1) not stored. Zero is specialcased to have both zero exponent and mantissa. Duncan Murdoch 
From: Roberto Ricardi <robertoar@ar...>  20031027 02:10:54

Hi all, How can I read an I/O port from c (not c++) code in mingw?. The only source Im read, by the while, was 'mnsd' info and http://www.naughter.com/ (free app to serial ports, with MFC, VC). Thanks in advance Roberto 
From: psksvp <psksvp@cc...>  20031027 11:07:07

depend on your os, NT4, W2K and XP won't allow you to real i/o port direc= tly in user mode. you will need a software call Port95NT which will allow you= to user api inport and outport. but I think, the best way is to use CreateFile(..) api psksvp  Original Message =20 From: "Roberto Ricardi" <robertoar@...> To: <mingwusers@...> Sent: Monday, October 27, 2003 1:05 PM Subject: [Mingwusers] =BF How to read an I/O ports in mingw ? > Hi all, > > How can I read an I/O port from c (not c++) code in mingw?. The only > source Im read, by the while, was 'mnsd' info and > http://www.naughter.com/ (free app to serial ports, with MFC, VC). > > Thanks in advance > > Roberto > > > > > > >  > This SF.net email is sponsored by: The SF.net Donation Program. > Do you like what SourceForge.net is doing for the Open > Source Community? Make a contribution, and help us add new > features and functionality. Click here: http://sourceforge.net/donate/ > _______________________________________________ > MinGWusers mailing list > MinGWusers@... > > You may change your MinGW Account Options or unsubscribe at: > https://lists.sourceforge.net/lists/listinfo/mingwusers > 
From: Roberto Ricardi <robertoar@ar...>  20031109 04:58:57

Hi all, I got a float single, manage it in a binary form in an unsigned int. And wish to recover the float form. The magnitudes range never be greather than +/ 32k. to manage a float we can do: Sign * 2^m * 1.F ( where m = E 127 and F = mantissa). To reconstruc with: r = 0.0 /* this is float */ n = Mantisa /* unsigned, mantissa constructed in binary */ n = n  0x3F800000; /* this meant 'or' with E127 = 0, positive */ now try to 'or' the binary equiv. in the float variable r = r  n; /* meant 1.F */ compiler cant manage float and unsigned 'or', maybe assuming not both 32 bits long ? the next cant be managed too, of course: r = 2^m * r; /* meant 2^m * 1.F */ How can I construct a float from a binary unsigned equiv. value ? Thanks a lot in advance Rob 
From: Peter Barada <peter@th...>  20031109 05:42:05

>I got a float single, manage it in a binary form in an unsigned int. And >wish to recover the float form. >The magnitudes range never be greather than +/ 32k. > >to manage a float we can do: Sign * 2^m * 1.F ( where m = E 127 and F >= mantissa). > >To reconstruc with: > > r = 0.0 /* this is float */ > n = Mantisa /* unsigned, mantissa constructed in binary */ > n = n  0x3F800000; /* this meant 'or' with E127 = 0, positive */ > >now try to 'or' the binary equiv. in the float variable > > r = r  n; /* meant 1.F */ > >compiler cant manage float and unsigned 'or', maybe assuming not both 32 >bits long ? >the next cant be managed too, of course: > > r = 2^m * r; /* meant 2^m * 1.F */ > >How can I construct a float from a binary unsigned equiv. value ? Use a union to hold bothe the float and the binary representation of the float: float transmute(unsinged int mantissa) float f; union { float f; unsigned int i; } fi; fi.i = mantissa; /* Mantissa is a value in the lower 23 bits , a fraction where 0x007ffff is 1 ulp less than one. */ fi.i = 0x3f800000; /* set exponent and sign bits */ f = fi.f; /* interpret fi.i as binary representaiton of a float */ return(f); }  Peter Barada peter@... 
From: Duncan Murdoch <dmurdoch@pa...>  20031109 12:52:06

On Sun, 9 Nov 2003 00:41:48 0500 (EST), you wrote: >Use a union to hold bothe the float and the binary representation of >the float: > >float transmute(unsinged int mantissa) > float f; > union { > float f; > unsigned int i; > } fi; > > fi.i = mantissa; /* Mantissa is a value in the lower 23 bits , a > fraction where 0x007ffff is 1 ulp less than one. */ > fi.i = 0x3f800000; /* set exponent and sign bits */ > f = fi.f; /* interpret fi.i as binary representaiton of a float */ > return(f); >} That looks wrong. The mantissa should be normalized, with the most significant bit (always 1) not stored. Zero is specialcased to have both zero exponent and mantissa. Duncan Murdoch 
From: Peter Barada <peter@th...>  20031109 19:26:34

>>Use a union to hold bothe the float and the binary representation of >>the float: >> >>float transmute(unsinged int mantissa) >> float f; >> union { >> float f; >> unsigned int i; >> } fi; >> >> fi.i = mantissa; /* Mantissa is a value in the lower 23 bits , a >> fraction where 0x007ffff is 1 ulp less than one. */ >> fi.i = 0x3f800000; /* set exponent and sign bits */ >> f = fi.f; /* interpret fi.i as binary representaiton of a float */ >> return(f); >>} > >That looks wrong. The mantissa should be normalized, with the most >significant bit (always 1) not stored. Zero is specialcased to have >both zero exponent and mantissa. > >Duncan Murdoch Yes, you're right. Here's a function that *should* do it all. I've done some cursory tested it, but nothing exhaustive... #define SPF_PREC 23 /* how many bits of precision in a IEEE singleprecision float */ #define ASSUMED_ONE (1<<SPF_PREC) /* where the assumed one is */ #define EXPONE (1<<SPF_PREC) /* what to add to incremnet exponent */ /* * Convert a *signed* fractional value held in 'frac' that is in the * range of 0..1, where 0 is 0x0 and 1 is (1<<bits), 1 is (1<<bits). */ float transmute (int frac, int bits) { union { float f; unsigned int i; } fi; unsigned int exponent, sign; /* If too many bits, then reutrn a NaN */ if (bits >= 32) { fi.i = 0x7fc00000; return (fi.f); } sign = 0; if (frac < 0) { frac = frac; sign = 0x80000000; /* set the sign bit */ } else if (!frac) return (float)0.0; /* weed out special case of zero */ /* If the fraction is 1, return +/ 1.0 */ if (frac == (1<<bits)) return sign ? 1.0 : 1.0; /* if the fraction has more precision than the float than shift the mantissa down, else up so that the 1 is in position. Ignore rounding. */ if (bits > SPF_PREC) frac >>= (bits  SPF_PREC); else frac <<= (SPF_PREC  bits); /* start with an exponent of 1 */ exponent = 0x3f800000; /* Now normalize the mantissa until we have the first significant bit in the assumed one position. */ while (!(frac & ASSUMED_ONE)) { exponent = EXPONE; frac <<= 1; } /* clear the assumed one so it doesn't pollute the exponent */ frac &= ~ASSUMED_ONE; fi.i = sign  exponent  frac; return (fi.f); }  Peter Barada peter@... 
From: Roberto Ricardi <robertoar@ar...>  20031111 06:44:09

Thanks a lot, Peter & Duncan. union work great ! Roberto Ricardi wrote: > Hi all, > > I got a float single, manage it in a binary form in an unsigned int. > And wish to recover the float form. > The magnitudes range never be greather than +/ 32k. > > to manage a float we can do: Sign * 2^m * 1.F ( where m = E 127 and > F = mantissa). > > To reconstruc with: > > r = 0.0 /* this is float */ > n = Mantisa /* unsigned, mantissa constructed in binary */ > n = n  0x3F800000; /* this meant 'or' with E127 = 0, positive */ > > now try to 'or' the binary equiv. in the float variable > > r = r  n; /* meant 1.F */ > > compiler cant manage float and unsigned 'or', maybe assuming not both > 32 bits long ? > the next cant be managed too, of course: > > r = 2^m * r; /* meant 2^m * 1.F */ > > How can I construct a float from a binary unsigned equiv. value ? > > Thanks a lot in advance > > Rob > > > > > > >  > This SF.Net email sponsored by: ApacheCon 2003, > 1619 November in Las Vegas. Learn firsthand the latest > developments in Apache, PHP, Perl, XML, Java, MySQL, > WebDAV, and more! http://www.apachecon.com/ > _______________________________________________ > MinGWusers mailing list > MinGWusers@... > > You may change your MinGW Account Options or unsubscribe at: > https://lists.sourceforge.net/lists/listinfo/mingwusers > > 
Sign up for the SourceForge newsletter:
No, thanks