> I am delighted that Version 1 of GO is about to be released. However,
> the lack of native support for Decimal Types troubles me greatly. It
> troubles me all the more because GO is such a breath of fresh air in
> most other respects. Yet when I see that GO already has native support
> for complex numbers, I wonder who or what is setting priorities here.
The Go team is setting priorities.
It is far too late to add fixed point decimal support to Go 1. Sorry.
> - The general fixation on floats (if you excuse the pun) appears to be
> a historical quirk due to the early ties between programming languages
> and the physical sciences.
That could be historically true. Today I think it's simply that
processors have well-standardized hardward support for floating point
values. Hardware support for fixed point decimal types is much less
advanced. As far as I know none of the Go targets currently support it.
> - Using custom decimal classes or libraries is inefficient in number-
> crunching applications.
But it is no less efficient than adding a fixed point decimal type to
the language which is not supported in processor hardware.
> - If lack of underlying native C support was not an issue for complex
> numbers, it should not be an issue for fixed-point decimals.
The C language has supported complex numbers since the C99 standard over
10 years ago.
> - It is not good enough to say that "GO does not need to show
> leadership" on this issue.
On the other hand, it would be a drastic mistake for Go to add the wrong
sort of fixed point decimal type. Can we be confident about the exact
characteristics of future hardware implementations of fixed point
decimal?
Ian
> I appreciate the time pressure for 1.0 but is it at least possible to
> allow for a *native* decimal type to be introduced in the "near"
> future on the basis that it is better "a little late" than never.
> Perhaps as early as 1.1 or 1.2 if no inadvertent backward
> compatibility issues are introduced in 1.0.
Fortunately no change in Go 1 is required in order to introduce a native
decimal type at a later date. The predeclared types (int, float64,
etc.) are not keywords. New predeclared types can be introduced at any
time without breaking any existing working Go 1 programs. (Not that we
have any current plans to introduce new predeclared types, but nothing
precludes it.)
> In terms of choosing a format, I believe that IEEE has already
> published a standard.
True, but a published standard is one thing, and actual implementations
are another. I'm only aware of a single hardware implementation of that
standard, for PowerPC. (Intel ships a software implementation, and so
does the gcc compiler.)
> I also feel that the issue of hardware support is a red herring as
> long as a decimal standard has been agreed. I recall that native
> floats were used in programming languages long before floating-point
> CPUs came on the scene -- and they were notoriously inefficient.
Of course, but those formats varied considerably. A language like C can
get away with defining float and double very loosely, so that it can
adapt to different standards. A language like Go wants to be more
precise in describing behaviour. It would be a real mess if Go
specified a fixed point decimal type, and it turned out that hardware
wound up supporting a somewhat different fixed point decimal type.
> Even without hardware support, low-level
> software emulation is still more efficient than user-defined classes
> or add-on libraries.
That is not true in Go, at least not if you mean runtime efficiency.
Ian
I suggest introducing it in version 1.2000000000000002.
--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/plus
http://niemeyer.net/twitter
http://niemeyer.net/blog
-- I'm not absolutely sure of anything.
It seems natural to imagine that a package can be created defining the
approriate data type and operations, using assembly if necessary when
relevant. It doesn't really make a difference, except maybe for the
fact that the operations will not be inlined.
Rémy.
> I am however surprised at your remark that low-level emulation of
> native decimal types would make little difference to GO's run-time
> efficiency compared to user-defined classes or add-on libraries. Does
> the GO compiler not have the ability to encapsulate decimal operations
> in machine code optimised for Intel/AMD/ARM architectures?
Yes, but in effect all the operations would turn into function calls to
that optimized machine code. And that can be done for an external
package as well--that is, you can write a Go package in assembly code if
you so choose, though it's obviously painful.
(I guess there would be one noticeable difference with compiler support:
the compiler would translate string literals to fixed point at compile
time, whereas any straightforward package support would do it at
runtime.)
Ian
Denis
Yes!
And think that, by sole inertia, if Go version 1 is not sufficiently
_different_, then people will stay by C, C++ (or even C# or Java). The
whole project would be a failure (just like D, despite all its
qualities) because of its conformism, Google's marketing power may not
be enough to compensate. It needs to open right track precisely where
historical weight stand on the wrong ones. (And there are many, or all
kinds, even syntactic like the use of '=' for assignment instead of
equality ,-)
Denis (newcomer)
In mathematics notation '=' doesn't mean equality in the same way that
'==' means equality in Go.
In maths, '=' means 'is the same as' , it's a statement of fact not a question.
Which makes it far closer to the assignment operation that 'Go' uses it for.
A test for equality isn't something very useful in mathematics since
it doesn't often deal with user input or things changing value during
a calculation. Thing aren't equal or inequal, they either have a
relationship or don't. Which is why programming languages had to
create their own symbol for the "are these the same value?" semantics.
- jessta
--
=====================
http://jessta.id.au
We've had (AFAIK) two threads on the mailing list on decimal support,
this being the second. Are there any third-party decimal packages
available, eg. on the Projects Dashboard[1] or cat-v.org[2]? Something
which could serve as a basis for a standardized implementation? This
to me seems like the bare minimum criteria to qualify a feature as
even "moderately desirable".
[1] http://godashboard.appspot.com/project
[2] http://go-lang.cat-v.org/pure-go-libs
> 2. Is it necessary to reserve any keywords for backward compatibility?
> 3. Has the IEEE standard received sufficient support from key players
> (I am thinking of Intel, AMD, ARM, IBM, etc)?
> 4. Would adding Google to that list not give the emerging standard
> some critical mass (leadership?)
> 5. What better way to set the cat among the pigeons than by supporting
> built-in decimals in GO?
Based on the above, all of these questions appear to be putting the
cart before the horse.
--
Aram Hăvărneanu
i'm not sure you can.
if Go adopts a particular standard that turns out not to
be the standard adopted by hardware manufacturers, then
the Go runtime would have to use software emulation.
a package that directly uses the hardware implementation
may then be faster.
> 1. Is there general agreement that built-in decimal support is a very
> desirable feature in the near future (this is not obvious yet).
I have not seen general agreement. Certainly nothing is going to happen
before the Go 1 release.
> 2. Is it necessary to reserve any keywords for backward compatibility?
No.
> 3. Has the IEEE standard received sufficient support from key players
> (I am thinking of Intel, AMD, ARM, IBM, etc)?
Has Intel supported the standard other than by providing a software
library? What have AMD and ARM done?
> 4. Would adding Google to that list not give the emerging standard
> some critical mass (leadership?)
The small Go team, which works on an open source project, does not
represent Google. In any case the other companies you list are hardware
vendors, unlike Google.
> 5. What better way to set the cat among the pigeons than by supporting
> built-in decimals in GO?
Since you ask, I think a better way would be writing a popular software
package which uses fixed point decimal and would run faster with
hardware support.
Ian
Me too. What will drive it is use. To make your point, you're driving
a dichotomy that either it is a native type or it doesn't matter. This
is a false dichotomy.
What "native types" give you that packages don't is convenient syntax
for using things which are, after all, just numbers. Otherwise I can't
see a problem with trying decimals out with a package and perhaps
eventually picking the best offering to go native with.
Chris
--
Chris "allusive" Dollin
I don't think there is. What I don't see is the use case for built-in
decimal support. Is there a use case other than dollar quantities? If
it's only useful for a given field of endeavor, then it's hard to see
it belonging in the language.
--
David Roundy
David
--
David Roundy
You're helping Vincent's point. There are very well known use cases
for using decimals. I even feel funny saying that.
It's not even worth debating this issue further. Go will have support
for decimals. Whether they will be native at some point is up for
debate, but it's just a matter of time until a good package supporting
that is available. Also, even if it does become known by the compiler
at some point, having a package is a great first step.
Actually, finding out that go had no support for decimals was what was
setting me off from it on the first glance - it took a while to come
back. That the very cautious presented and well-considered call for a
build-in type leads to a discussion instead of simply a line added to
the milestones document upsets me in a disturbing way.
My full support for Vincent's call and my wish, that very soon this
little missing brick will be added. With the release of version one a
lot of potential users will get attracted, and I fear some of them will
keep the lack of decimals in mind for a long time to talk down every
approach within their premises to use go for anything.
In another thread these days I read the FUD word used pretty
questionable. I think lack of decimals is what FUD is about - find a
little weakness in the fabric, try to stick your finger into it until
the thing looks like a bulky waste to everyone.
Its a pity that such a good effort like go will suffer from the fuddies.
I dont want it to, so lets get the decimal on the list, even if it does
not make it into number one.
Cheers,
C.
Well, that did not quite pan out ... although the Burroughs 3500
series was a decimal architecture IIRC and was used for quite some
time. They were a very interesting architecture.
All of which is to say, don't take too much for granted.
At the same time, if you open up the doors to base 10, how soon do the
base 12 guys come in and demand that too :-)
ron
Botched the reply on my phone, sorry.
"I feel like a very important point is being missed here:
Writing a package > proposing an addition to the spec, this close to a major milestone at the very least.
Code speaks louder than email."
Typed on glass
> Actually, finding out that go had no support for decimals was what was
> setting me off from it on the first glance - it took a while to come
> back. That the very cautious presented and well-considered call for a
> build-in type leads to a discussion instead of simply a line added to
> the milestones document upsets me in a disturbing way.
The most serious issue at hand is when Go should commit to a specific
standard for fixed-size decimal numbers. Keeping decimal support in a
package makes it relatively easy to change the supported standard, at
the cost of having convenient operator syntax and convenient literals
(it is important to note that there is no other cost). Adding a
specific decimal standard to the language proper makes it very hard to
change.
I think the strongest argument in favor of Go adopting decimals in the
language proper would be a hardware implementation in a processor that
Go actually supports, a hardware implementation which matches the
existing PowerPC implementation.
Vincent has argued that Go should lead in this area, implying that if Go
commits to a standard the addition of the types to the language will
help encourage adoption by other lanugages. I am far less confident.
Also, I simply do not believe that Go adding decimals to the language
will have any effect whatsoever on whether a processor manufacturer will
add them to their hardware.
Ian
> Also, I simply do not believe that Go adding decimals to the language
> will have any effect whatsoever on whether a processor manufacturer will
> add them to their hardware.
BCD instructions have been in architectures for at least a
half-century. The 8086 (and hence everything that followed) had them.
I just ran across a usage recently of them in fact. A video bios used
an 8086 bcd instruction in some weird invalid way. The purpose? To
ensure an 'invalid instruction trap' and fault out of the bios, i.e.
to terminate it --- in other words, the use was not exactly what was
intended
:-)
It's not like base 10 instructions have not been there. I believe
they're used in COBOL. I have not seen people running to emulate that
support in other places.
But, hey, the source to the compiler is there -- is there anything
stopping you from adding it to see if people like it?
It's a plan 9 style compiler, not gcc. You would be delighted, I
think, to see how beautiful these are inside -- and how easily you can
tinker with them.
ron
Once Go 1 is complete, Go could benefit from a proposal for letting
user types use operators.
Perhaps Go is not the right tool for those users, but hopefully you
can see how "life's simpler without it" might sound dismissive.
Make your response to the group if you like, but I believe that you
are trolling.
FWIW, decimal numbers is the wrong context to argue that a + b is confusing.
FWIW, decimal numbers is the wrong context to argue that a + b is confusing.
I fully share your views and support your request. [See also other post
to come.]
Think at this: if we had reasonably efficient decimals, why use binary
nums *at all*? Binary nums originally are an artifact of HW leaking into
language design, later propagated from lang to lang without any
reasonable reason ;-)
The only case for binaries may be number-crunching apps extremely
demandingin UC cycles _and_ which do not require decimal exactness;
precisely because, since the HW is binary, there may always remain a
slight diff in performance in their favor --everything else beeing
equal. (But if decimals were to become a de facto standard, diffs in
design investment would certainly by far compensate this: everything
else would _not_ be equal.)
Denis
Thank you,
Denis
The problem about creating a "fantastic decimal library" is that,
without operator overloading and formatting support, it will be used
reluctantly and only in the most compelling applications, creating
little impetus "from the masses" for a built-in type. While operator
overloading might be desirable in this particular case, I can also
empathise with those who see this feature as "the thin end of the
wedge".
And yet neither you nor Vincent have given any.
David asked a valid question, and no one has
answered it. I read the linked discussions and
searched around and couldn't find any other
examples myself.
The very strong claim is being made that fixed
point should be the default and floating point
the exception, but I haven't seen strong enough
evidence to even justify fixed point in the core
language.
--
Alex
http://c2.com/cgi/wiki?FloatingPointCurrency
In a previous post I said:
Concur. (Money and measurements, neither of which is uncommon or
obscure, come to mind.)
Chris
--
Chris "allusive" Dollin
> Imagine trying to express the following using a decimal library:
>
> y = c1 * (d1 + d2 + d3) / (d4 + d5)
y = c1.Times(d1.Add(d1).Add(d2).Add(d3)).Div(d4.Add(d5))
Sure, it's more clumsy, but it's straightforward.
Which argument leads directly to C++ and Python reigning supreme as the
programming languages in areas like finance where fixed point is needed.
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel...@ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: rus...@russel.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
I was responding to the tone of the previous message which seemed to
suggest that using methods to express the y= expression would be unthinkably
horrible. It isn't. It's just clumsy.
I too would prefer to be able to write arithmetic operations (for some sane
notion of "arithmetic") using infix operator syntax or a close
facsimile. I don't
think you're going to get that into Go for decimals without previous production
of a decent decimal library as a minimum, /unless/ a more general solution
to the "nice infix syntax for methods" issue turns up.
Denis
Denis
But I ask you again, would you or Rob find yourself making the same
arguments about floats or ints?
I don't think so.
And what about GO's built-in support for complex
numbers? Is that not a complete contradiciton?
Hmm. Go does not have class hierarchies. It has very fast and cheap goroutines (not available in C/C++). It has powerful interfaces. Go gives you the ability to reflect.I think there are many differentiating factors between Go and C/C++. Same with Java and Python (and Go is compiled!) I believe Go is the first language to be able to properly say it is the next generation "C" language (small, simple, easy to understand, efficient (all things C++ is not)).As they say "Try it, you'll like it!"-Paul
Your post is quite ironic. You start off by saying it is *hard to
imagine* that the majority of the code would be mathematical, and then
you end with an allegory about someone with a lack of imagination!
Having written a fair amount of scientific code, the number crunching
is a lot more of 5% of the total (financial applications may be
different).
You are correct that it is certainly possible to write these
applications without operator overloading. By that measure, these
applications can be written in Fortran, Visual Basic, etc.
Notation does have an impact on readability. Unfortunately, we don't
have an objective measure of readability. It is also very difficult
to compare the cost of extending the Go language to the complexity of
the programs users will write. Without these measures, I suspect this
argument will go around and around. In the meantime, the Go
developers are prioritizing those tasks that are important to them,
which is perfectly acceptable.
P.S. Go is not a magic bullet. Just because it is in Go, does not
mean it will be trivial to write.
> - Native dec16, dec32 and dec64 types would be a major selling point
> for GO.
Uhm, doesn't the most widely used decimal type use a sign, a 96-bit
mantissa, and an exponent for the scaling factor (10^0 to 10^-28)?
That would make it dec102 or something like that. It's not exactly
fixed-point, either.
If decimal fixed-point is so important, why are both Excel and
OpenOffice Calc using binary floating-point instead? This is
especially strange since Excel's predecessor, Multiplan, used decimal
floating-point.
David's original question had asked "anything other than dollar quantities."
I can understand the argument in that case, because fractional
pennies don't actually exist. This is not true of general measurements,
for which scientific and engineering purposes typically require as
much precision as possible.
--
Alex
No!
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
In one of the many threads about this (five years ago!) I mentioned Mike Colinshaw's excellent work:This is an excellent and correct library. I can be inspiration for a native Go implementation.On Wed, Apr 5, 2017 at 4:51 PM, Mandolyte <ceci...@gmail.com> wrote:Doesn't help with operators, but noticed this:https://www.cockroachlabs.com/blog/apd-arbitrary-precision-decimal-package/
On Wednesday, March 29, 2017 at 1:27:22 PM UTC-4, a.mat...@ra-micro.de wrote:No!We want to use operators like + , - , * and / with decimal values. This is actualy a "No Go" !
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/YczDW-4QMtE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.