Number names (float, float32, ...)

1,250 views
Skip to first unread message

Mark Summerfield

unread,
Jan 12, 2011, 1:02:08 PM1/12/11
to golang-nuts
Hi,

Why isn't 'float' simply an alias for 'float64' just like 'byte' is an
alias for 'uint8'?

Those who want to minimize memory use will use float32s---they already
have to convert if they want to use the standard math package, so making
float an alias for float64 wouldn't affect them.

And for those using 'float' it would mean eliminating the need to
convert all the time to use the math package. (It might increase the
memory their applications use though, if their implementation happened
to currently use 32-bit floats for float.)

Nor would it preclude Go supporting 'quad' precision 128-bit floats in
the future (float128s), although they'd need their own version of the
math package (qmath?).

--
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
C++, Python, Qt, PyQt - training and consultancy
"Advanced Qt Programming" - ISBN 0321635906
http://www.qtrac.eu/aqpbook.html

roger peppe

unread,
Jan 12, 2011, 1:16:03 PM1/12/11
to Mark Summerfield, golang-nuts
this has been discussed previously.

i thought there was an issue on this topic, but i couldn't find one.
here are a couple of links to old discussions on the topic:

http://groups.google.com/group/golang-nuts/browse_thread/thread/d7545b8325c43e15
http://groups.google.com/group/golang-nuts/browse_thread/thread/25d8068784971c15/65a2cf75662838a6

peterGo

unread,
Jan 12, 2011, 2:15:04 PM1/12/11
to golang-nuts
Mark,

Changing the implementation-specific size of of float to match float64
instead of float32, since the math library is uses float64, has often
been requested.

Here's a recent response from Russ.

On Sep 9 2010, 6:19 pm, Russ Cox <r...@google.com> wrote:

> We have mooted the idea of making float be 64 bits
> and the idea of dropping it entirely. I don't remember
> what the end result was other than that nothing happened.
> We don't use floating point very much.

http://groups.google.com/group/golang-nuts/msg/2791da5b83347e4a

Peter

John Asmuth

unread,
Jan 12, 2011, 5:22:07 PM1/12/11
to golang-nuts


On Jan 12, 2:15 pm, peterGo <go.peter...@gmail.com> wrote:
> On Sep 9 2010, 6:19 pm, Russ Cox <r...@google.com> wrote:
>
> > We have mooted the idea of making float be 64 bits
> > and the idea of dropping it entirely.  I don't remember
> > what the end result was other than that nothing happened.
> > We don't use floating point very much.

"We don't use floating point very much."

Lots of people do, though!

Or at least, I consider myself to be the representative of the group
"people that are like me". We use float64 all the time :)

- John

David Roundy

unread,
Jan 12, 2011, 5:33:51 PM1/12/11
to John Asmuth, golang-nuts

I don't think that in-context Russ' statement meant that he thought
floating point wasn't important, but rather that he and the other core
developers aren't keen on making decisions on floating point without
outside input.

Since that quote was made, he's floated the idea (which seemed likely
to be implemented) of removing the "float" type entirely. Personally,
I think that's a good approach. Type synonyms are ugly and
potentially confusing (and there's only one of them in the language,
as far as I know: byte). Making everyone type "float64" is the same
number of characters as the "double" we're all accustomed to typing
(unless you're coming from fortran), and is clearer to newcomers.
--
David Roundy

Gabor

unread,
Jan 14, 2011, 2:37:52 PM1/14/11
to golang-nuts
For completeness,
here is a more recent and more promising reply from Russ:

On Dec 13 2010, 9:50 pm, Russ Cox <r...@golang.org> wrote:
> > Whenever I touch a float, float32 or float64
> > I wish to use mathematical functions with it.
> > Right now this is only possible with float64,
> > so float and float32 are pretty useless for math.
> > I do not know whether this situation
> > will ever change but I feel it should.
> > To make the default float 64-bit
> > and math functions accepting this float
> > might not be the ideal solution, I admit.
>
> There is a tentative plan to delete float from
> the language and make constants like 1.5
> have default type float64, precisely so that
> they will be usable with the mathematical functions.
>
> Russ
Reply all
Reply to author
Forward
0 new messages