473,386 Members | 1,803 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.

Automatic Number Formatting

Hi there,

I have several hundred statistical data sets, which are being displayed on the fly. The values can vary between 0.001 and 10000000 for the different sets.

Now, when displaying some statistics like min and max, it is ok to strip the decimal places for most of the variables, but not for all.

293873982.35 becomes 293873982
0.04 becomes 0

So, I implemented a series of IFs, to specify that if the value is between 1 and 10, than 1 decimal; if smaller as 1 than 2....

But I wonder if there is a more elegant way to this. A small mathematical algorithm, which does it "better".

Thanks for any ideas!
Mar 23 '09 #1
5 1312
TheServant
1,168 Expert 1GB
You mean significant figures? That's not mine, just someone else's function I found for you.
Mar 23 '09 #2
You mean significant figures? That's not mine, just someone else's function I found for you.
Interesting, could use this one for another part of the project. But no, I think more in the terms of "pay attention when to show how many decimals, depending on the "size" of the number".

So, I think it's close to what I want, but not really.
Mar 23 '09 #3
Dormilich
8,658 Expert Mod 8TB
what about scientific display (like 1.234e+8 or 1.234e-2), maybe that's close to what you want?
Mar 23 '09 #4
@Dormilich
No, thanks, but that's too complicated for "normal" users. :-)
Mar 23 '09 #5
TheServant
1,168 Expert 1GB
@luftikus143
I'm afraid the normal number rounding options of decimal places or significant figures are pretty much the only standard. If you show us your code already done we can maybe streamline it, but I doubt you will find a single function without making your own.
Mar 23 '09 #6

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

Similar topics

7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
9
by: Paul Rubin | last post by:
I'm trying the super() function as described in Python Cookbook, 1st ed, p. 172 (Recipe 5.4). class A(object): def f(self): print 'A' class B(object): def f(self):
4
by: pjac | last post by:
I need assistance in creating an Automatic tracking number that appears in a textbox that looks like: 2004-001. The first part of the number is based on the year, the second part is generated from...
29
by: Natan | last post by:
When you create and aspx page, this is generated by default: using System; using System.Collections; using System.Collections.Specialized; using System.Configuration; using System.Text; using...
1
by: Russell Mangel | last post by:
I am using VS2005. When I paste source code into the code window, VS2005 formats like the following: public MsgRecipientReader() : base() { }
2
by: dcyale | last post by:
I have a report with the following paragraph: ="This BA presents a " & & " determination for the " & & " and associated habitat. We would appreciate you processing the biological opinion by " &...
2
by: bryars | last post by:
I want to write some SQL which results in an automatic conversion of a datetime to a string in a format suitable for the Language of the connection (either by explicitly setting the Language in the...
0
by: swamimeenu | last post by:
Hi, I need to add a automatic serial number in datareport in vb without having tht field in database.. but the remaining fields are connected from db... how to generate automatic serial number...
5
by: trss | last post by:
Has anyone experienced automatic memoization by any C++ compiler before? The program coded as a solution for the problem based on the famous 3n +1 problem, both of which are given below, is...
2
Pittaman
by: Pittaman | last post by:
Hello I am creating some crystal reports (for visual studio 2005) based on the content of certain .NET objects. I'm doing this in .NET 2.0. For one of them I'm using a Cross-table to summarize...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
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
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.