Board index » delphi » Floating point numbers
bius_cmayh...@pop.birmingham-us.crosswinds.net (Chuck Mayhall)
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
|
bius_cmayh...@pop.birmingham-us.crosswinds.net (Chuck Mayhall)
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Floating point numbers
OK guys, I've looked through the group and found a lot of good
information. Now, here's my problem. I'm trying to read 4 bytes of information that is stored on a Unix 68k machine. These for bytes represent a floating point number in the format simular to "97.4". When I try to read this with BP7 I don't come up with anywhere close to the same number I get on the unix machine. I know it has something to do with "big endian" , "little endian" but I don't know what to do in BP7 to read or manipulate it to get the correct number. Can any one help with this? Thanks, |
Ing. Franz Glase
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Floating point numbersQuoteChuck Mayhall wrote: type. Motorola stored numbers in the "wrong" order (as the Intel people say :-) i.e. the most significant byte on the lowest byte address. If you dont know the format, are there at least a few known numbers and You find a related article regarding real number representation in the |
Glenn Grotzing
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Floating point numbersOn Mon, 01 Mar 1999 00:47:02 GMT, Quotebius_cmayh...@pop.birmingham-us.crosswinds.net (Chuck Mayhall) wrote: Good FWP, btw. Go to http://www.crosswinds.net for unlimited space and no forced ads whatsover... ========================================================== Quote>OK guys, I've looked through the group and found a lot of good does have something to do with Big endian / little endian, you will have to shift the information. A byte is made up of 8 bits, with values of 0 or 1. To accomplish this, you'd have to isolate the bit values and move them Boolean operators AND, SHL, and SHR will help. Here's an idea. Not much easier way to do it too but haven't thought of it yet. program shift; var function reverse_byte(inbyte: byte): byte; begin end; begin That reverses the bits in a byte. Then you could swap the bytes in Hope it helps. If not, hope it gets you on the right track. |
Chuck Mayha
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Floating point numbers"Ing. Franz Glaser" <meg-gla...@eunet.at> wrote: Quote>Chuck Mayhall wrote: cotton and turns it into yarn (thread). These can range from 0.0 to 100.0. The usual range however is from 85.0 to 98.0. The file that is stored is 400 bytes long which represent 100 machines (100 4 byte records). Looking at this file, each 4 byte recored usually begins with 42 hex. I have manualy manipulated the number (which I may not have a full grip on what's actually going on) and still con't get it to come out to the same number the unix machine gives. - Hide quoted text - - Show quoted text - Quote>You find a related article regarding real number representation in the |
Chuck Mayha
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Floating point numbersQuotethed...@lebowski.com (Glenn Grotzinger) wrote: for? Quote>Good FWP, btw. Go to http://www.crosswinds.net for unlimited space later found that I could take the first byte and multiply it by 256 and then add the second byte to it instead of shifting the bytes around. I wonder if I could come up with somthing like taht for 4 bytes? |
Arthur Hoornwe
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Floating point numbersSTOP! This is WRONG! Little-endian and big-endian means that the BYTES are Assuming the data are really in binary format, not ASCII, Arthur M. Hoornweg Program test; VAR f,k:integer; -- Arthur M. Hoornweg |
G?ran Andersso
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Floating point numbersQuote>I've done something simular to this before, but with just 2 bytes. I Actually, when you multiply by 256, the compiler will recognise this as the /GreenGhost |
Dr John Stockto
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Floating point numbersJRS: In article <36d9fcb9.27704...@news.iland.net> of Mon, 1 Mar 1999 03:10:37 in news:comp.lang.pascal.borland, Glenn Grotzinger Quote<thed...@lebowski.com> wrote: order, though it is quite likely that the four bytes are in the wrong order. Chuck should post a table of half a dozen examples of the input in Hex and, to be helpful, convert to binary and to be very helpful convert the numbers too The answer should then be obvious, assuming reasonable encoding on the -- |
Chuck Mayha
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Floating point numbersDr John Stockton <j...@merlyn.demon.co.uk> wrote: Quote>JRS: In article <36d9fcb9.27704...@news.iland.net> of Mon, 1 Mar 1999 the numbers: 42 C7 12 F7 which, by what i've come up with from you guys, is 99.5. I used the following, posted here in a reply, and it worked. Program test; VAR f,k:integer; begin Thanks for all the responces. If anyone has a shorter method, I would Thanks again, |
Glenn Grotzing
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Floating point numbersOn Mon, 1 Mar 1999 08:22:09 +0100, "Arthur Hoornweg" Quote<arthur.hoorn...@email.de.net> wrote: are reversed based on the bits. But it's all relative, since there's so many different formats out there. |
Todd Fis
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Floating point numbersOn Mon, 01 Mar 1999 03:57:27 GMT, Chuck Mayhall Quote<bius_cmayh...@pop.birmingham-us.crosswinds.net> wrote: replace above, so my guess is that FWP means "free webspace provider" or something similar. Free Whatever Provider. =) Quote>> Glenn's example snipped only involves the bytes, not the bits. Here's a snippet to help: {$N+} value : single absolute leData; begin leData[ 0 ] := beData[ 3 ]; { converting beData into leData } writeln( 'the value is ', value ); Cheers, Todd |
Dr John Stockto
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Floating point numbersJRS: In article <7bidd8$...@lotho.delphi.com> of Wed, 3 Mar 1999 04:22:00 in news:comp.lang.pascal.borland, Todd Fiske Quote<tfi...@delphi.com> wrote: {$N+} value : single absolute leData; begin leData[0] := swap(beData[1]); { converting beData into leData } writeln( 'the value is ', value ); Swap tested, above untested. -- |
Todd Fis
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Floating point numbersOn Wed, 3 Mar 1999 12:21:54 +0000, Dr John Stockton Quote<j...@merlyn.demon.co.uk> wrote: I don't prefer brevity or cleverness in things that can be difficult to Plus, I'm always happy to provide opportunities for further optimising. =) - Hide quoted text - - Show quoted text - Quote> {$N+} what your swap() routine looks like. What's faster, two swap calls and two word assignments, or four byte assignments? Cheers, Todd |
Dr John Stockto
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Floating point numbersJRS: In article <7c45nh$...@lotho.delphi.com> of Tue, 9 Mar 1999 22:01:21 in news:comp.lang.pascal.borland, Todd Fiske Quote<tfi...@delphi.com> wrote: interpolate); it is done by the compiler. A := Swap(B) ; The code for the case in question should be similar, as a fixed element -- |
1. How do I round a floating point number?
2. Help! Floating point numbers
3. Problem/bug with BDE aggregate calc and floating point numbers
4. Really huge floating point numbers
5. How to convert floating point numbers?
6. splitting a floating point number
7. Looking for Spinedit for floating point numbers...