|
Why decimals instead of doubles though? Not trying to question the decision, I'd like to understand for myself.
|
|
|
|
|
My guess is one of two: Either, the application calls for the higher precision (almost 29 decimal digits for decimal, less than 17 decimal digits for double), but the numeric range is sufficiently large. This level of precision is rarely needed, except in some extreme scientific calculations.
Or, the application calls for full control of roundoff errors, with exact value representation of e.g. decimal fractions, rather than a binary approximation. This is a common requirement in e.g. accounting systems. (An alternative to decimal is of course to use a long value to represent an integer number of millicents or whatever the required precision of the transactions. Using decimal will usually require fewer application code lines, as you can deal directly with the unscaled amounts.)
When I explain programming to beginners (and also to some at intermediate level needing some correction...), I know from experience that for some, understanding the principal difference between int and float is difficult. So I rather call it 'counts' and 'measurements'. The price of an apple is not a measurement, it is a count of the pennies you have to pay. So we use an int - int is a synonym for a count. If you weigh that apple, you do not count the grams, or milligrams, or micrograms - you will not get a measurement exactly right. So we use a float - float is a synonym for a measurement value. Even if you claim that the weight of the apple is exactly 123.456 grams, it nevertheless is a measurement, calling for a float, not a count of milligrams.
Making beginners understand the difference between a count and a measurement is far easier than to explain int and float. In that framework, I really would like to consider decimal as a "counting" value, with the extension that it lets us count not only Euros or dollars, but even cents and tenths of a cent. With BCD, this was very explicit at the representation level as well; with decimal, it is blurred. C# documentation classifies it as a 'floating point numeric type'. Yet, decimal is functionally like BCD values, rather than as measurement float / double. Also by implementation, it is a scaled integer (i.e. counting) value.
I think using decimal for measurement values is an abuse. If you really need more than the 17 digits of a double, then you should go for one of the 'infinite precision' libraries provided for almost any language. (Writing one is not that difficult - I made one myself in my student days.) If you measure the dimension of the universe down to the millimeter, you are still making a measurement, not a count.
And if the range of decimal is not sufficient - e.g. if you want to count all the atoms in the universe - and decimal doesn't provide a sufficient numeric range, then you should go for a software 'infinite integer range' library. (I never saw one, but writing one is almost down to the trivial level, if you really have the need! Biggest problem is formatting the number as text!)
|
|
|
|
|
Greetings May I inquire if the beginners should simply be informed that int's represent the integers and float's the real numbers? Kind Regards Cheerios
|
|
|
|
|
The problem is that lots of people consider a weight of 454 gram an integer numeric value, rather than a real, especially if they use a digital scale. If you ask "the man in the street" to explain "integer" and "real" numbers, you may be surprised by the (lack of) answers you get! (There is nothing 'un-real' about, say, 'five' ) You cannot expect beginners in programming to have a solid background in mathematics.
(Almost) everyone have little problems distinguishing between counting and measuring. Well, that is my experience. YMMV.
|
|
|
|
|
It sounds to me like you could write an interesting article on this application of decimal.
|
|
|
|
|
|
Speak for yourself.
|
|
|
|
|
If I saw this in my local food store, I might give it a try.
Unless it appears to be sweet like a fruit jam. A smoked, meaty bredspread on dark, whole grain bread could be very tasty, assuming that it would be something like if you put some bacon through your meat grinder.
Sometimes, you use a tiny amount of sugar in meats to round off the taste, without making it 'sweet'. If this is 50% bacon and 50% sugar, then it is not for me!
|
|
|
|
|
A couple of weeks ago I tried unsuccessfully to get slots for the both of us to get vaccinated, but the website kept crashing and the phone number was busy all day. In the end we got a slot for just one of us at a location some 60 miles from our home! Yuck!
This morning the second batch of bookings became available, a mere 8 miles for home. We got slots for the both of us for Friday. And the website only crashed some 10 times before we got our bookings! The government in Florida can be proud. Their IT guys are getting better! Still, we are both in a very good mood now.
Get me coffee and no one gets hurt!
|
|
|
|
|
You're lucky.
Here, normal folks will have to wait a few months before the vaccine (after healthcare personel, old folks, teachers .... )
According to this :
"There are between 11,704,258 and 22,456,373 people in front of you in the queue for a COVID vaccine across Canada"
I'd rather be phishing!
|
|
|
|
|
Well my wife and I are both in the 75 years plus group, which helped a lot to get a booking! Folks younger than 65 are going to wait a loooong time.
Get me coffee and no one gets hurt!
|
|
|
|
|
One of our health officials said yesterday that we don't actually need another vaccine to be approved. We will have enough.
Eventually.
I love Canada, but this is not a country you could ever accuse of moving with reckless haste.
cheers
Chris Maunder
|
|
|
|
|
Our Justin just ordered (in french) 20,000,000 new doses.
So that'll help (I don't know the production speed of those vaccines)
and to be fair, they did the CERB quickly last spring.
I'd rather be phishing!
|
|
|
|
|
Makes up for all the procrastination, blockades, ethics vioations, racism, corporate pandering, ...
The velvet glove (money) versus the fist.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
|
Herself had her first jab (Oxford/AstraZeneca) last Wednesday and has had no problems at all, though some of the other workers did take time off complaining of headaches, weariness, and arm pain. (I suspect Skiveitis in most cases though.)
She hasn't caught Covid again since the jab, I can confirm (negative test).
Good luck - you shouldn't need it!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks!
Get me coffee and no one gets hurt!
|
|
|
|
|
Now, if only Florida could provide unemployment benefits to the poor sods who lost their jobs due to the pandemic.
Oops, I forgot. It is all due to the COBOL programs used by the state's benefits department!
😫😳
|
|
|
|
|
Hey, I resemble that remark. I worked on that COBOL to VB.Net conversion several years ago - all the reports are done in VB. Net (errors and all)
A human being should be able to change a diaper, plan an invasion, butcher a hog, navigate a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects! - Lazarus Long
|
|
|
|
|
If you're in a high risk group, good for you. Personally I'm going to wait to see what side effects start appearing. I'm concerned these vaccines were rushed through testing so while I have no concerns about the vaccine payload, I am concerned about the vaccine vehicle.
|
|
|
|
|
Tracking my birthday-present-coffee-machine and it was picked up by FedEx at 16:46.
But it's 16:33 now ...
The time in Italy - where the machine is made - is one hour ahead, of course. But they do all tracking in courier local time rather than use UTC and convert to client local time when they display it ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
Nah - that's next month. I'm just getting the pressie in early so it can get caught up by lockdowns, Brexit, zombie apocalypse, delivery by UPS*, vegan protests, ... and I still get it on the day.
* Like that could ever happen. UPS: UrParcelSmashed
It's coming by FedEx who are a little better, but make up their own "customs import rules"and charge you to query it.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: rather than use UTC and convert to client local time when they display it
Because that would solve all of their problems, right?
Storing UTC is not a silver bullet | Jon Skeet's coding blog[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Why don't we use UTC all over the place and abandon local time zones entirely?
Why is there a "need" to everywhere call it 08:00 when people go to work and 16:00 when they return home, when the socalled "same time" really can vary among 24 different real times across the world?
|
|
|
|
|