473,386 Members | 1,734 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,386 software developers and data experts.

Is there already a discrete range class?

Hello All,
I'm looking for a data class that can take a
floating point input and round it to the nearest
float based on a predefined set of boundaries.
In other words, an arbitrary float comes in and only
a discrete set of floats come out.

Something to the effect of----
//Given the float breakpoints,
float boundaries[] = {
11.5
,22.0
,24.0
,28.0
,39.0
};

//And the following code
DiscreteRange discreteFloat(boundaries);

discreteFloat.set(26.0);
float floatAnswer = discreteFloat.get();

//Here the 'floatAnswer' would equal 28.0

Anyone know of a class (set of classes) that already provides such
functionality? I've searched the web, but I don't think I'm
using the right terminology for such a critter. It'd be nice
if it was a template, and allowed for rounding up or down.
Any suggestions??

And it seems trivial, but if it already exists
and has been tested...why reinvent.

Happy Friday,
Slarty
Jul 19 '05 #1
3 1736
WW
Sim Nanda wrote:
Hello All,
I'm looking for a data class that can take a
floating point input and round it to the nearest
float based on a predefined set of boundaries.
In other words, an arbitrary float comes in and only
a discrete set of floats come out.


I don't knwo of any existing class.

Do you want to make it always round up (or always down)? Because then if I
am not mistaking then you can use the lower_bound/upper_bound functions of
the standard library.

--
WW aka Attila
Jul 19 '05 #2
Thanks for the reply.
I was hoping there'd be a full featured class
with everything I'd ever dreamed of (much like
that whole soul mate scam).
I hadn't thought of lower_bound/upper_bound
they will be helpful in writing the class.

Let's say I come up with a dynamite class for
this functionality and I wanted to share it,
where is the best place to put it up?

I guess that's a general question I've had,
what sites (if any) does everyone for C++ code sharing?

bye,
Slarty
Jul 19 '05 #3
WW
Sim Nanda wrote:
Thanks for the reply.
I was hoping there'd be a full featured class
with everything I'd ever dreamed of (much like
that whole soul mate scam).
I hadn't thought of lower_bound/upper_bound
they will be helpful in writing the class.

Let's say I come up with a dynamite class for
this functionality and I wanted to share it,
where is the best place to put it up?

I guess that's a general question I've had,
what sites (if any) does everyone for C++ code sharing?


Look at http://www.boost.org

--
WW aka Attila
Jul 19 '05 #4

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

Similar topics

2
by: Francois Vanderseypen | last post by:
Imagine a discrete 2D space of any size. Say, you have a 100x100 pixels (.net) panel and you have discrete cells of 10x10 pixels. Thinking e.g. of the game of life. I would like to draw a line in...
10
by: jack | last post by:
Hi guys, I am working on a project which requires an implementation of discrete event simulation in C using linked lists. I would greatly appreciate if someone could provide with some sources...
0
by: Alison Givens | last post by:
I have the following problem. (VB.NET 2003 with CR) I have a report with a multiple-value discrete value and a rangevalue. The report shows fine in the viewer, but when I hit the export to pdf...
3
by: toton | last post by:
Hi, I want ro iterate over a few container class within a range specified, instead of begin & end. How to construct a range class, which takes start & end, and iteration is available within that...
0
by: toton | last post by:
Hi, I have a view class for a vector, which stores different range for a few vectors, and provides a way to iterate over the range. The range class takes a pair of iterator, as given in post...
0
by: lrobo01 | last post by:
I'm having a problem with Crystal report.net with ASP.NET. The problem occurs when exporting the report. The report uses a discrete parameter with multiple values. When the report is loaded into...
0
by: lrobo01 | last post by:
I'm having a problem with Crystal report.net with ASP.NET. The problem occurs when exporting the report. The report uses a discrete parameter with multiple values. When the report is loaded into...
2
by: Affan | last post by:
Hi, I am writing a discrete event simulator and want to simplify the analysis of multipath by trigging an arrival of multipath based on a the receiver distance from sender- say 'd'- and a...
2
Banfa
by: Banfa | last post by:
Right I am actually using SQL Server 2005, however this is a general question about table design that is probably relevant to any database engine so I am going to ask it here since this is the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
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,...
0
jinu1996
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 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.