473,383 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

storing floating point data with using float or double

Hi,

I've developed a testing application that stores formatted results in a
database. Recently it was requested that I add the ability to generate
graphs from the raw, un formatted test results (100,000+ float values)

I don't intend to store all of the 100,000 datapoints, but rather a subset
of say 250. Due to the volume of testing that we need and the volume of
results stored, I need to be VERY careful with data size and keep things as
lean and small as possible.

Given the example data: (-5.2485, 5.9875, -1.2548, 7.5842)
Those samples represent our data value boundaries, they won't get any bigger
than that, they are signed and they are floating point.

I don't need the precision of a float, the above values would be fine to be
stored as:
-5.29
5.99
-1.25
7.58

A couple of ideas I have come up with is to try compressing the array of 250
floats and storing the compressed binary in the DB BLOB field. I also
though about breaking the values into an sbyte and a byte like this:
-5.29

represented as:
sbyte l = -5;
byte r = 29;

This would save me to bytes from using a float. If I then compressed this
"byte data" I could save even more space.

Anyway, I have never done any of this before and wanted to invite you guys
to offer any suggestions or past experiences you might of had with doing
something like this.

As you can see, I'm not real sure what I'm doing ;0)

Thanks for reading,
Steve
May 5 '06 #1
6 2898
Subject was supposed to be "withOUT using float or double" - sorry
"Steve" <sk**@skle.com> wrote in message
news:uN*************@TK2MSFTNGP05.phx.gbl...
Hi,

I've developed a testing application that stores formatted results in a
database. Recently it was requested that I add the ability to generate
graphs from the raw, un formatted test results (100,000+ float values)

I don't intend to store all of the 100,000 datapoints, but rather a subset
of say 250. Due to the volume of testing that we need and the volume of
results stored, I need to be VERY careful with data size and keep things
as lean and small as possible.

Given the example data: (-5.2485, 5.9875, -1.2548, 7.5842)
Those samples represent our data value boundaries, they won't get any
bigger than that, they are signed and they are floating point.

I don't need the precision of a float, the above values would be fine to
be stored as:
-5.29
5.99
-1.25
7.58

A couple of ideas I have come up with is to try compressing the array of
250 floats and storing the compressed binary in the DB BLOB field. I also
though about breaking the values into an sbyte and a byte like this:
-5.29

represented as:
sbyte l = -5;
byte r = 29;

This would save me to bytes from using a float. If I then compressed this
"byte data" I could save even more space.

Anyway, I have never done any of this before and wanted to invite you guys
to offer any suggestions or past experiences you might of had with doing
something like this.

As you can see, I'm not real sure what I'm doing ;0)

Thanks for reading,
Steve

May 5 '06 #2
You can store the values as fixed point values in shorts (Int16). You
would be able to get a precision of three decimals if you'd like.

Multiply the values by 1000 and convert to short:

-5249
5988
1255
7584

The numbers you could store this way would range from -32.768 to 32.767.

Eat my shorts. ;)

Steve wrote:
Hi,

I've developed a testing application that stores formatted results in a
database. Recently it was requested that I add the ability to generate
graphs from the raw, un formatted test results (100,000+ float values)

I don't intend to store all of the 100,000 datapoints, but rather a subset
of say 250. Due to the volume of testing that we need and the volume of
results stored, I need to be VERY careful with data size and keep things as
lean and small as possible.

Given the example data: (-5.2485, 5.9875, -1.2548, 7.5842)
Those samples represent our data value boundaries, they won't get any bigger
than that, they are signed and they are floating point.

I don't need the precision of a float, the above values would be fine to be
stored as:
-5.29
5.99
-1.25
7.58

A couple of ideas I have come up with is to try compressing the array of 250
floats and storing the compressed binary in the DB BLOB field. I also
though about breaking the values into an sbyte and a byte like this:
-5.29

represented as:
sbyte l = -5;
byte r = 29;

This would save me to bytes from using a float. If I then compressed this
"byte data" I could save even more space.

Anyway, I have never done any of this before and wanted to invite you guys
to offer any suggestions or past experiences you might of had with doing
something like this.

As you can see, I'm not real sure what I'm doing ;0)

Thanks for reading,
Steve

May 5 '06 #3
If your data posted is typical of your data ... why not just store

(int16) data * 100

then on the way out just divide by 100 ? :)

Cheers,

Greg
"Steve" <sk**@skle.com> wrote in message
news:uN*************@TK2MSFTNGP05.phx.gbl...
Hi,

I've developed a testing application that stores formatted results in a
database. Recently it was requested that I add the ability to generate
graphs from the raw, un formatted test results (100,000+ float values)

I don't intend to store all of the 100,000 datapoints, but rather a subset
of say 250. Due to the volume of testing that we need and the volume of
results stored, I need to be VERY careful with data size and keep things
as lean and small as possible.

Given the example data: (-5.2485, 5.9875, -1.2548, 7.5842)
Those samples represent our data value boundaries, they won't get any
bigger than that, they are signed and they are floating point.

I don't need the precision of a float, the above values would be fine to
be stored as:
-5.29
5.99
-1.25
7.58

A couple of ideas I have come up with is to try compressing the array of
250 floats and storing the compressed binary in the DB BLOB field. I also
though about breaking the values into an sbyte and a byte like this:
-5.29

represented as:
sbyte l = -5;
byte r = 29;

This would save me to bytes from using a float. If I then compressed this
"byte data" I could save even more space.

Anyway, I have never done any of this before and wanted to invite you guys
to offer any suggestions or past experiences you might of had with doing
something like this.

As you can see, I'm not real sure what I'm doing ;0)

Thanks for reading,
Steve

May 5 '06 #4
Oh man, I need a rock to crawl under and hide!
Thanks for the tip, jeez.. I should know that, shouldn't I? I think I was
over complicating and skipped past simple and easy. I hate that.

Have a great weekend (and maybe Cinco de Mayo, depending where you live)

"Greg Young" <Dr*************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
If your data posted is typical of your data ... why not just store

(int16) data * 100

then on the way out just divide by 100 ? :)

Cheers,

Greg
"Steve" <sk**@skle.com> wrote in message
news:uN*************@TK2MSFTNGP05.phx.gbl...
Hi,

I've developed a testing application that stores formatted results in a
database. Recently it was requested that I add the ability to generate
graphs from the raw, un formatted test results (100,000+ float values)

I don't intend to store all of the 100,000 datapoints, but rather a
subset of say 250. Due to the volume of testing that we need and the
volume of results stored, I need to be VERY careful with data size and
keep things as lean and small as possible.

Given the example data: (-5.2485, 5.9875, -1.2548, 7.5842)
Those samples represent our data value boundaries, they won't get any
bigger than that, they are signed and they are floating point.

I don't need the precision of a float, the above values would be fine to
be stored as:
-5.29
5.99
-1.25
7.58

A couple of ideas I have come up with is to try compressing the array of
250 floats and storing the compressed binary in the DB BLOB field. I
also though about breaking the values into an sbyte and a byte like this:
-5.29

represented as:
sbyte l = -5;
byte r = 29;

This would save me to bytes from using a float. If I then compressed
this "byte data" I could save even more space.

Anyway, I have never done any of this before and wanted to invite you
guys to offer any suggestions or past experiences you might of had with
doing something like this.

As you can see, I'm not real sure what I'm doing ;0)

Thanks for reading,
Steve


May 5 '06 #5
lol.. it's not often you can say "Eat my shorts" and have it actually be
relevant to the issue, good one ;0)
thanks for the suggestion, this is what I will do.
Have a great weekend!

"Göran Andersson" <gu***@guffa.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
You can store the values as fixed point values in shorts (Int16). You
would be able to get a precision of three decimals if you'd like.

Multiply the values by 1000 and convert to short:

-5249
5988
1255
7584

The numbers you could store this way would range from -32.768 to 32.767.

Eat my shorts. ;)

Steve wrote:
Hi,

I've developed a testing application that stores formatted results in a
database. Recently it was requested that I add the ability to generate
graphs from the raw, un formatted test results (100,000+ float values)

I don't intend to store all of the 100,000 datapoints, but rather a
subset of say 250. Due to the volume of testing that we need and the
volume of results stored, I need to be VERY careful with data size and
keep things as lean and small as possible.

Given the example data: (-5.2485, 5.9875, -1.2548, 7.5842)
Those samples represent our data value boundaries, they won't get any
bigger than that, they are signed and they are floating point.

I don't need the precision of a float, the above values would be fine to
be stored as:
-5.29
5.99
-1.25
7.58

A couple of ideas I have come up with is to try compressing the array of
250 floats and storing the compressed binary in the DB BLOB field. I
also though about breaking the values into an sbyte and a byte like this:
-5.29

represented as:
sbyte l = -5;
byte r = 29;

This would save me to bytes from using a float. If I then compressed
this "byte data" I could save even more space.

Anyway, I have never done any of this before and wanted to invite you
guys to offer any suggestions or past experiences you might of had with
doing something like this.

As you can see, I'm not real sure what I'm doing ;0)

Thanks for reading,
Steve

May 5 '06 #6
V
Hi Steve,

If it is really only a storage problem, then you could probably invest
some time and implement any of the compression algorithms available in
C#, and then maybe simply concatenate your numbers into a string and
then compress them using such an algorithm (huffman or arithmetic
compression), and then simply store the compressed string in a varchar
field.

For your dataset size, it will be really fast to do the
compress/decompress and the size of the resultant (compressed) varchar
will also be pretty small.

Regards,
Vaibhav
www.nagarro.com

May 5 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Anton Noll | last post by:
We are using Visual Studio 2003.NET (C++) for the development of our software in the fields digital signal processing and numerical acoustics. One of our programs was working correctly if we are...
15
by: michael.mcgarry | last post by:
Hi, I have a question about floating point precision in C. What is the minimum distinguishable difference between 2 floating point numbers? Does this differ for various computers? Is this...
10
by: Bryan Parkoff | last post by:
The guideline says to use %f in printf() function using the keyword float and double. For example float a = 1.2345; double b = 5.166666667; printf("%.2f\n %f\n", a, b);
7
by: ma740988 | last post by:
Consider the equation (flight dynamics stuff): Yaw (Degrees) = Azimuth Angle(Radians) * 180 (Degrees) / 3.1415926535897932384626433832795 (Radians) There's a valid reason to use single...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.