Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Is there already a discrete range class?

Reply
Thread Tools

Is there already a discrete range class?

 
 
Sim Nanda
Guest
Posts: n/a
 
      10-03-2003
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
 
Reply With Quote
 
 
 
 
WW
Guest
Posts: n/a
 
      10-03-2003
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


 
Reply With Quote
 
 
 
 
Sim Nanda
Guest
Posts: n/a
 
      10-06-2003
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
 
Reply With Quote
 
WW
Guest
Posts: n/a
 
      10-06-2003
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
static discrete range in generate statements SameerDS VHDL 4 03-24-2010 04:33 PM
Discrete range in CASE hssig VHDL 17 01-18-2010 12:51 PM
VHDL For-Loop Index .. can it be of discrete range ? omara007 VHDL 0 05-05-2009 11:56 PM
error "choice must be discrete range" with CASE Manfred Balik VHDL 3 04-30-2005 11:18 AM
where to have discrete color prints made? Beowulf Digital Photography 14 08-30-2003 06:44 PM



Advertisments