|
...or rounding to the most significant digit.
(I'd suggest that we call this "politicians rounding")
|
|
|
|
|
Rounding to one significant digit.
|
|
|
|
|
OK, bad example...
123 would be 120.
125 would be 120.
126 would be 130.
etc. etc.
The point not being the number of significant digits you end up with, but the fact that the rounding is happening at 5 and 6 rather than the more usual 4 and 5.
Almost, but not quite, entirely unlike... me...
|
|
|
|
|
Sounds like you want to do Round Half Down + Significant then.
|
|
|
|
|
See my other answer, or Daves.
|
|
|
|
|
I think the word you are looking for is 'wrong'.
Software Zen: delete this;
|
|
|
|
|
http://en.wikipedia.org/wiki/Rounding[^]
"Round half down to nearest integral multiplier power of 10"
Peter Wasser
"The whole problem with the world is that fools and fanatics are always so certain of themselves, and wiser people so full of doubts." - Bertrand Russell
|
|
|
|
|
Thanks, "Round half down" was the term I was looking for.
Almost, but not quite, entirely unlike... me...
|
|
|
|
|
how I would go about explaining what it's doing to the users. If you owe us money, we get more; if we owe you money, you get less.
“I have diligently numbered the days of pure and genuine happiness which have fallen to my lot: They amount to 14.” Abd-Ar Rahman III, Caliph of Cordoba, circa 950CE.
|
|
|
|
|
This is standard rounding
The irony is that people are so used to bankers rounding they get confused when they see ordinary rounding, but this is the kind you probably learned about in school!
Disregard, I'm an idiot
modified 8-Sep-14 1:41am.
|
|
|
|
|
JMK-NI wrote: This is standard rounding
No it isn't.
There is a huge difference between standard rounding and significant rounding.
There are also many different types of rounding scheme depending on the application: http://en.wikipedia.org/wiki/Rounding[^]
|
|
|
|
|
Well knock me down!
It's 6:30AM, I haven't had coffee yet!
|
|
|
|
|
Well it's now 6:43am, my first meeting with my supervisory team was an hour ago and I have already spoken with my boss onshore, so the day is well underway.
Only another 14 or 15 hours still to go.
Feeling already.
|
|
|
|
|
JMK-NI wrote: Disregard, I'm an idiot Well, JMK-NI, don't worry too much: you are in the place for idiocy. It's kind of like a "contagious skin rash," here, on the Lounge, it breaks out in different people, and makes different people scratch in different places, while others scratch their heads.
cheers, Bill
“I have diligently numbered the days of pure and genuine happiness which have fallen to my lot: They amount to 14.” Abd-Ar Rahman III, Caliph of Cordoba, circa 950CE.
|
|
|
|
|
|
My understanding of rounding to N significant figure is like this:
1234 to 3 significant figures = 1230
1235 to 3 significant figures = 1240
1236 to 3 significant figures = 1240
The trouble is, I need
1234 to 3 significant figures = 1230
1235 to 3 significant figures = 1230
1236 to 3 significant figures = 1240
The point is, rather than rounding up or down depending on whether the N+1th digit is 4 or 5, but whether it is 5 or 6.
Almost, but not quite, entirely unlike... me...
|
|
|
|
|
How about "N Significant Half-Down Rounding[^]"?
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
Round half down + Significant.
|
|
|
|
|
Cheers.
I think "round half down" is the term I needed.
Almost, but not quite, entirely unlike... me...
|
|
|
|
|
So depending on how you want to treat negative numbers you want either "Significant digits round half down" or "Significant digits round half towards zero".
|
|
|
|
|
All values are positive, due to the nature of the application.
"Round half down" was the term I was looking for.
Thanks for your help.
Almost, but not quite, entirely unlike... me...
|
|
|
|
|
The 1.5 -> 1 is a little strange. Except for that you can use
double MagicFormula(double x)
{
var d = Math.Log10(x);
var f = Math.Pow(10.0, d);
var res = Math.Round(x / f, 0) * f;
var res2 = Math.Round(res, 0);
return res2;
}
Michael Pauli
|
|
|
|
|
|
There's going to be a beer discussion on HTML5 tomorrow at the Intel conference and I want your thoughts on the following
1. Is HTML5 the right choice for building an app? Obviously if it's a web app, then yes, but is it the right choice if you're writing, say, Windows 8 apps?
2. Are there any misconceptions about HTML5? To me: not from where I stand, but I wonder if this is universal. HTML5 isn't a language, it's markup, and it's the Javascript and CSS3 that give it its power. It's slow - though not as slow as yesterday - and it's casual with types, which can make it a nightmare to debug. These are all known quantities though.
3. What's the main issue with using HTML5 to create apps? Apart from speed? And type safety? And the fact it's a functional language when many devs thing in OOP terms? And the fact that things never work perfectly between browsers and the HTML5 "standard" is often merely a serving suggestion?
4. Does HTML5 actually have a future beyond the browser? Will it all go away and we'll be writing our apps in Go or Swift on all platforms? Does HTML5 even have a future on the webbrowser?
cheers
Chris Maunder
|
|
|
|
|
1. Probably not today, but soon.
2. I don't think I have any either - but then again, if I do, I wouldn't think they were misconceptions! The main thing I hear time and again is "slow" - form people who jsut assume it must be slow and haven't tried it. I tend to find it's not too slow at the client side (certainly faster than some of the XAML stuff I've used) if it's well written, but the background delay fetching data makes it seem much slower at times, because folk compare it to a more local solution.
3. Speed is still an issue - but becoming less so. Typescript helps with type safety and OOPism to some extent. Things working perfectly across platforms? It's a lot better than it was.
4. I don't think it will go away to be replaced by anything for a LONG time - because all browses would have to adopt whatever the new thing is - can you see IE supporting Swift?!
My question would be, will Javascript be allowed to mature to the point it is a 'real' language.
Or will another language come along to replace it?
There seems to be no reason I can see for someone not to write a new language that has all of the goodness of a real, strongly typed, OO language, while being scriptable and having native DOM access.
So the problem then becomes one of browser introduction - nobody will use it on a web site unless most browsers support it - no web browser will support it if there's nothing in it for them..
Typescript or something like it is probably the best solution - effectively have a front-end compiler for a language that spits out javascript rather than bytecode.
PooperPig - Coming Soon
|
|
|
|