Is there already a discrete range class?

Discussion in 'C++' started by Sim Nanda, Oct 3, 2003.

  1. Sim Nanda

    Sim Nanda Guest

    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
    Sim Nanda, Oct 3, 2003
    #1
    1. Advertising

  2. Sim Nanda

    WW Guest

    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
    WW, Oct 3, 2003
    #2
    1. Advertising

  3. Sim Nanda

    Sim Nanda Guest

    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
    Sim Nanda, Oct 6, 2003
    #3
  4. Sim Nanda

    WW Guest

    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
    WW, Oct 6, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Manfred Balik
    Replies:
    3
    Views:
    4,239
    Brian Drummond
    Apr 30, 2005
  2. Alex Gittens
    Replies:
    1
    Views:
    447
    Peter Hansen
    Jul 10, 2005
  3. omara007
    Replies:
    0
    Views:
    652
    omara007
    May 6, 2009
  4. hssig

    Discrete range in CASE

    hssig, Jan 4, 2010, in forum: VHDL
    Replies:
    17
    Views:
    2,755
    hssig
    Jan 18, 2010
  5. SameerDS
    Replies:
    4
    Views:
    1,183
    joris
    Mar 24, 2010
Loading...

Share This Page