OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "go.h" | 5 #include "go.h" |
6 #define TUP(x,y) (((x)<<16)|(y)) | 6 #define TUP(x,y) (((x)<<16)|(y)) |
7 | 7 |
8 static Val tocplx(Val); | 8 static Val tocplx(Val); |
9 static Val toflt(Val); | 9 static Val toflt(Val); |
10 static Val tostr(Val); | 10 static Val tostr(Val); |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 } | 881 } |
882 return n; | 882 return n; |
883 } | 883 } |
884 | 884 |
885 Node* | 885 Node* |
886 nodcplxlit(Val r, Val i) | 886 nodcplxlit(Val r, Val i) |
887 { | 887 { |
888 Node *n; | 888 Node *n; |
889 Mpcplx *c; | 889 Mpcplx *c; |
890 | 890 |
| 891 r = toflt(r); |
| 892 i = toflt(i); |
| 893 |
891 c = mal(sizeof(*c)); | 894 c = mal(sizeof(*c)); |
892 n = nod(OLITERAL, N, N); | 895 n = nod(OLITERAL, N, N); |
893 n->type = types[TIDEAL]; | 896 n->type = types[TIDEAL]; |
894 n->val.u.cval = c; | 897 n->val.u.cval = c; |
895 n->val.ctype = CTCPLX; | 898 n->val.ctype = CTCPLX; |
896 | 899 |
897 if(r.ctype != CTFLT || i.ctype != CTFLT) | 900 if(r.ctype != CTFLT || i.ctype != CTFLT) |
898 fatal("nodcplxlit ctype %d/%d", r.ctype, i.ctype); | 901 fatal("nodcplxlit ctype %d/%d", r.ctype, i.ctype); |
899 | 902 |
900 mpmovefltflt(&c->real, r.u.fval); | 903 mpmovefltflt(&c->real, r.u.fval); |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 mpmulfltflt(&ad, &rv->imag); // ad | 1257 mpmulfltflt(&ad, &rv->imag); // ad |
1255 | 1258 |
1256 mpmovefltflt(&v->real, &ac); | 1259 mpmovefltflt(&v->real, &ac); |
1257 mpaddfltflt(&v->real, &bd); // ac+bd | 1260 mpaddfltflt(&v->real, &bd); // ac+bd |
1258 mpdivfltflt(&v->real, &cc_plus_dd); // (ac+bd)/(cc+dd) | 1261 mpdivfltflt(&v->real, &cc_plus_dd); // (ac+bd)/(cc+dd) |
1259 | 1262 |
1260 mpmovefltflt(&v->imag, &bc); | 1263 mpmovefltflt(&v->imag, &bc); |
1261 mpsubfltflt(&v->imag, &ad); // bc-ad | 1264 mpsubfltflt(&v->imag, &ad); // bc-ad |
1262 mpdivfltflt(&v->imag, &cc_plus_dd); // (bc+ad)/(cc+dd) | 1265 mpdivfltflt(&v->imag, &cc_plus_dd); // (bc+ad)/(cc+dd) |
1263 } | 1266 } |
OLD | NEW |