473,663 Members | 2,694 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(b oundaries);

discreteFloat.s et(26.0);
float floatAnswer = discreteFloat.g et();

//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 1761
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
2323
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 this discrete space, but it can't be smooth, it has to be aliased or in a block-form corresponding to the pixel resolution of the underlying space. How to approximate a 'Graphics.DrawLine' in function of the pixelated space? Thanks for your...
10
5249
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 on how to approach DES. Please help me out. Thanks, Jack
0
1202
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 button, it only uses one of two discrete values. This is the code: Dim BeginPeriode As String Dim EindPeriode As String
3
2846
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 range only. Itaration may be const, bidiractional, forward or backward. Say I have a vector or other container class, like vector<intvec; and want to return a range class like range(vec.begin()+5,
0
1416
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 http://groups.google.com/group/comp.lang.c++/browse_thread/thread/6d41708a9929e71a/a282fc1288b1231f?lnk=gst&q=range&rnum=2#a282fc1288b1231f However, as the range class do not have a default ctor, and range is not known when view class is constructed...
0
1802
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 the crystal report view it shows all the values from the discrete parameter. But when I export the report it only shows the values from the last discrete parameter value enter. My code is listed below:
0
2803
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 the crystal report view it shows all the values from the discrete parameter. But when I export the report it only shows the values from the last discrete parameter value enter. My code is listed below:
2
2149
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 simulation parameter, say mpParam which gives the fraction of maximum range within which the reflecting surface is located (I know gross simplifications!). Note that for fraction beyond 1, there is no need for any event to be triggered as it will not be...
2
1439
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 busiest DB forum on the site. To start with I make no bones about the fact that the area I am really expert in is C/C++ programming on a variety of micro controls and computers. And the problem is this, what is the best (or correct) way to store a...
0
8436
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8771
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8548
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8634
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7371
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4182
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2763
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 we have to send another system
2
1757
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.