[ANN] math32 - library for float32 and complex64

339 views
Skip to first unread message

David Turnbull

unread,
Mar 14, 2014, 2:45:17 PM3/14/14
to golan...@googlegroups.com
math32 is a library for float32 and complex64 types. Everything from "math" and "math/cmplx" is available for 32-bit floats.

https://github.com/AE9RB/math32

Enjoy!

simon place

unread,
Mar 15, 2014, 12:18:25 PM3/15/14
to golan...@googlegroups.com
does this actually mean you can you just cut/paste float64 to float32 in existing code and have it work?

Message has been deleted

simon place

unread,
Mar 15, 2014, 1:21:49 PM3/15/14
to golan...@googlegroups.com

(reply to assembly code for float32 lib)

probably best thing to do, would be to simply copy as much as possible the float64 std lib, so as to have the same hardware dependencies.

mostly what seems to be needed is:

amd64:     ?????SD   ->   ?????SS

in x86;      F????   ->   F????S

and 8byes -> 4bytes in MOVes

for example: sqrt_amd64.s

     1	// Copyright 2009 The Go Authors.  All rights reserved.
     2	// Use of this source code is governed by a BSD-style
     3	// license that can be found in the LICENSE file.
     4	
     5	#include "../../cmd/ld/textflag.h"
     6	
     7	// func Sqrt(x float64) float64
     8	TEXT ·Sqrt(SB),NOSPLIT,$0
     9		SQRTSD x+0(FP), X0
    10		MOVSD X0, ret+8(FP)
    11		RET
needs this diff
     9		SQRTSS x+0(FP), X0
    10		MOVSS X0, ret+4(FP)
and 


     1	// Copyright 2009 The Go Authors.  All rights reserved.
     2	// Use of this source code is governed by a BSD-style
     3	// license that can be found in the LICENSE file.
     4	
     5	#include "../../cmd/ld/textflag.h"
     6	
     7	// func Sqrt(x float64) float64	
     8	TEXT ·Sqrt(SB),NOSPLIT,$0
     9		FMOVD   x+0(FP),F0
    10		FSQRT
    11		FMOVDP  F0,ret+8(FP)
    12		RET
diff

     9		FMOVS   x+0(FP),F0
    10		FSQRTS
    11		FMOVSP  F0,ret+4(FP)

BTW bear in mind i've only been looking at assembler since last week, so i could be missing something important.

and

the 386 is currently just guesses and is untested, but i hope to test and will report back.(i guess the 386 will actually work on amd64) 

David Turnbull

unread,
Mar 15, 2014, 1:27:18 PM3/15/14
to golan...@googlegroups.com
On Saturday, March 15, 2014 9:18:25 AM UTC-7, simon place wrote:
does this actually mean you can you just cut/paste float64 to float32 in existing code and have it work?

For the most part, yes, that's the idea.

I'm surprised nobody commented about the release of a floating point math library on "Pi day".

andrey mirtchovski

unread,
Mar 15, 2014, 2:10:18 PM3/15/14
to David Turnbull, golang-nuts
> I'm surprised nobody commented about the release of a floating point math
> library on "Pi day".

I would have, but your library is insufficiently irrational.

necl...@gmail.com

unread,
Jul 5, 2014, 12:45:01 PM7/5/14
to golan...@googlegroups.com
Hi David,

I can no longer find the repository.
Can you tell me why it was taken? Using an old version I have, I am safe?


Thank you,
Ignazio
Reply all
Reply to author
Forward
0 new messages