Advertisement

Two Questions (simple)

Started by May 30, 2000 02:11 AM
11 comments, last by Qoy 24 years, 7 months ago
OK, I have two simple questions... 1) I wrote a function to write a bitmap file, and in the MSDN docs it said that BITMAPINFOHEADER::biType (I think) should be ''BM''. But in my code it only works if it''s ''MB''. Does anyonw know why this is. 2) are doubles really faster than floats?
Strange problem with your MB/BM thing.
Inversion somewhere in your code ?
Transmission of data in the wrong order ?

Don''t know.

To my knowledge, double are slower than floats.
Our porcessors are optimized for 32bits data, so feed them with 32bit for maximum efficiency.
(Tis include using 32bit for a boolean, wasting memory for speed efficiency)

Basicaly, 32bits takes only one cycle to be transmitted in a 32bit wide bus, while 64bits takes two cycles, being slower.

Hope it helps.

-* Sounds, music and story makes the difference between good and great games *-
-* So many things to do, so little time to spend. *-
Advertisement
How do you set the value of biType? You should keep the byte ordering in mind. The values for ''B'' and ''M'' are 0x42 and 0x4D resp., so you would have to set biType as 0x4D42 instead of 0x424D.

Erik
OK, sorry, I meant BITMAPFILEHEADER::bfType, but all the same.

Im setting it like this:

fileHeader.bfType = ''MB'';

When I set it as ''BM'' it didn''t work, when I tried to load it in Paint Shop Pro it said it was an invalid file, (not a bitmap file) but when I changed it to ''MB'' it works...
The reason that ''BM'' does not and ''MB'' does work is because of the byte ordering of the Intel processor. Intel CPUs store the least significant part (in this case M) first, and then the most significant (in this case B). If you directly write biType (which is a 16 bit unsigned value) to a file (which happens when you use fwrite), the M (least signigicant byte) is stored first, and then the B (most significant byte).

Erik
What I do is just check if biType is 19778. It is a very simple solution.

------------------------
Captured Reality.

Edited by - nes8bit on May 30, 2000 8:16:38 PM
Advertisement
actually floats and doubles run at exactly the same speed on Intel FPU. the are both converted to 80-bit floats internally. thus the only difference is memory size. 4 bytes vs. 8 bytes.

about the bitmap thing. both "BM" and "MB" are supported because of the different endiness of computers it''s used on.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
Yes, nes. 19778 is the same as ''MB'' though, so there''s really no difference...
jenova, no offense, but are you on crack? doubles definitely run WAY slower than floats on intel fpu''s.
actually i have never tried crack. and why do you believe doubles run slower than floats when both formats are converted to 80-bit floats at the FPU level. and all commands are processed at 80-bits. so why would the external floating point size effect the computation speed of an FPU instruction when internally all FPU instructions are processed using 80-bit ST registers. i have been programming with assembler for almost ten years and i can show you plenty of documentation which supports my knowledge of the 80x87 FPU. other than memory storage size there should be no difference to the fpu instruction. maybe a clock cycle with the "fld" and "fstp" instructions. and i even doubt that.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

This topic is closed to new replies.

Advertisement