Hi, I'm running out of memory storing a large float array. One
acceptable workaround would be to reduce the float precision by
switching from the default, which is 4 bytes long, to a smaller one -
say, 2 bytes.
I'm using MSVC++ 6.0 and don't see any way to do this. Perhaps MS does
not provide a 2 byte float...? Appreciate your advice. Thanks :) 6 7282
Hi,
Is there anyway I could see the code? MSVC++ 6, is my favoured Editor, I
refuse to give it up.
The Code Master Th*************@hotmail.com
<sp******@yahoo.com> wrote in message
news:11********************@g47g2000cwa.googlegrou ps.com... Hi, I'm running out of memory storing a large float array. One acceptable workaround would be to reduce the float precision by switching from the default, which is 4 bytes long, to a smaller one - say, 2 bytes.
I'm using MSVC++ 6.0 and don't see any way to do this. Perhaps MS does not provide a 2 byte float...? Appreciate your advice. Thanks :)
OpenEXR has a fairly good 16-bit floating point type implementation in
C++. You cannot use it as drop-in replacement to 32-bit floating point,
though, for starters the range of values that can be stored is very
small. Works great for normalized or near normalized values (for color
for example this works great).
The implementation is same the Cg, HLSL and GLSL use, but it isn't
standard.. just de-facto standard. :)
persenaama wrote: OpenEXR has a fairly good 16-bit floating point type implementation in C++. You cannot use it as drop-in replacement to 32-bit floating point, though, for starters the range of values that can be stored is very small. Works great for normalized or near normalized values (for color for example this works great).
The implementation is same the Cg, HLSL and GLSL use, but it isn't standard.. just de-facto standard. :)
Would the OP consider fixed point? If so, s/he could use 16-bit ints
(short ints on many platforms). Without delving into the OpenEXR, I'm
guessing that it would incur a more serious performance hit than fixed
point calculations since it would require emulation software rather
since hardware support for 16-bit floats is generally unavailable. Of
course, performance may not be an issue for the OP.
Cheers! --M
mlimber wrote: Would the OP consider fixed point? If so, s/he could use 16-bit ints (short ints on many platforms). Without delving into the OpenEXR, I'm guessing that it would incur a more serious performance hit than fixed point calculations since it would require emulation software rather since hardware support for 16-bit floats is generally unavailable. Of course, performance may not be an issue for the OP.
That's an interesting suggestion. The float values I require are
strictly between 0.0 and 1.0. An unsigned short has range 0 to 65536,
so if I were to scale the floats into this range and cast to unsigned
short I would have an effective precision of 1.5e-5. I think that is
probably adequate, I'll try it - thanks for your help :) sp******@yahoo.com wrote: mlimber wrote: Would the OP consider fixed point? If so, s/he could use 16-bit ints (short ints on many platforms). Without delving into the OpenEXR, I'm guessing that it would incur a more serious performance hit than fixed point calculations since it would require emulation software rather since hardware support for 16-bit floats is generally unavailable. Of course, performance may not be an issue for the OP.
That's an interesting suggestion. The float values I require are strictly between 0.0 and 1.0. An unsigned short has range 0 to 65536, so if I were to scale the floats into this range and cast to unsigned short I would have an effective precision of 1.5e-5. I think that is probably adequate, I'll try it - thanks for your help :)
It's actually a widely used suggestion especially in scientific data
storage where you typically know the range of data and you have some
fixed significant digits. Take for example an instrument measuring sea
surface temperature to an accuracy of 10^-4 degrees. You can typically
calculate a range of values the temperature can take in a "specific"
body of water. You then use a linear function y = mx + b to scale the
floating point data to some integer type. This is good especially in
storing large data sets where you can cut double or single precision
down to int32 or int16 storage size. When we stored data in HDF files,
we would specify the m and b (slope and intercept) as attributes to
recover the data. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: franzkowiak |
last post by:
Hello,
I've read some bytes from a file and just now I can't interpret 4 bytes
in this dates like a real value.
An extract from my program
def l32(c):
return ord(c) + (ord(c)<<8) +...
|
by: napi |
last post by:
I think you would agree with me that a C compiler that directly
produces Java Byte Code to be run on any JVM is something that is
missing to software programmers so far. With such a tool one could...
|
by: Khuong Dinh Pham |
last post by:
I have the contents of an image of type std::string. How can I make a
CxImage object with this type.
The parameters to CxImage is:
CxImage(byte* data, DWORD size)
Thx in advance
|
by: Joriveek |
last post by:
I have a float variable like 123456789
I want to right truncate this and only display say only 8 right most values
all the time or otherwise filled by zeros if it is less than 8 digits, do
you...
|
by: Kenny ODell |
last post by:
I do not know how to convert from a byte array to a float, and back again. I
read data from a serial port into a byte (entire command structure which I
parse). I am able to sift the data and...
| |
by: Mario M. Mueller |
last post by:
Hi,
I have a binary file containing 3 byte float values (big endian). How can I
read them into python? The struct module does not work, since it expects 4
byte floats.
Any hints?
Mario
|
by: DWilli3501 |
last post by:
I have two short programs that use floating point numbers. The first gives an incorrect result. By simply placing a "cout" (or any executable line) in the correct location of the program I get a...
|
by: ssubbarayan |
last post by:
Hi all,
I am trying a program to convert floating point values to a byte array
and printing the same to the screen.The idea behind this is we already
have an existing function which can do byte...
|
by: Peter |
last post by:
Trying to convert string to byte array.
the following code returns byte array of {107, 62, 194, 139, 64}
how can I convert this string to a byte array of {107, 62, 139, 65}
...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |