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

A Function that Rounds to the nearest significant value

how to create a round function that allows the user to choose to round to any significant figures of his choice.
Sep 30 '11 #1
2 1610
Frinavale
9,735 Expert Mod 8TB
The first thing you need to do is determine what is required for this function.

So, you should first look up what is involved with rounding so that you understand what needs to be done.

After you have a good understand of what is involved with rounding, write down the steps required to accomplish this task in English (or your spoken language)...then translate that into C or C++ code.



-Frinny
Sep 30 '11 #2
donbock
2,426 Expert 2GB
You also need to specify what rounding rules you want to follow. For example, does 2.5 round to 2 or 3, does 3.5 round to 3 or 4. How do you want to round negative numbers? These are things you need to settle before you even start thinking about the software.
Sep 30 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tee | last post by:
Hi, Can we use thread.start on a function that has return value? I have a function that will take sometimes to run and it will return a string value, and I want to use thread.start to call...
13
by: Sara | last post by:
I have a query that pulls data for the month, using the Month End Date from a form (user enters) as criteria. It works. I want to use the same query to pull "month to date" data, on a weekly...
2
by: ThompsonJessical | last post by:
I am trying to use a button with the vba coding for SendObject Function to email a specific report based on the value of another field of the current record. The form is a continuous form and...
13
by: Steve McLellan | last post by:
Hi, Is there any reason why the VC2003 C++ compiler emits the error "Function must return a value" for global functions and not for class member functions? For example: int test() {
4
by: Mark Kamoski | last post by:
Hi Everyone. What is the real difference between writing a Sub versus writing a Function with no return value? It seems to me that both of these would need to compile to the same IL, so it...
5
by: Dmitriy Lapshin [C# / .NET MVP] | last post by:
Hi all, I think the VB .NET compiler should at least issue a warning when a function does not return value. C# and C++ compilers treat this situation as an error and I believe this is the right...
9
by: Aaron Gray | last post by:
Hi, Well I have gone and done it, got to the bottom of it. Nothing spectacular but its good to see how it is done. Now to distill the brew ... I am going to use sub threads of the thread...
12
by: chellappa | last post by:
hi All, function automatically returns the value,am not used "return" i am using Linux -gcc complier please tell me.... what is problem... source ===== #include <stdio.h> main() {
3
by: anupamsps | last post by:
HI all, This is my first posting in this forum. I am confused about how to write a function that returns a value rounded to the nearest value of a double variable say X. when X is positive...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
0
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...

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.