2 * Copyright (C) 2009 Rich Burridge
3 * Copyright (C) 2012 Robert Ancell
5 * This program is free software: you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation, either version 2 of the License, or (at your option) any later
8 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
12 private const int MAXLINE
= 1024;
14 private static Serializer result_serializer
;
16 static void solve (string equation
)
18 var e
= new
Equation (equation
);
21 e
.angle_units
= AngleUnit
.DEGREES
;
24 var z
= e
.parse (out ret
, null);
27 stdout
.printf ("%s\n", result_serializer
.to_string (z
));
28 else if (ret
== ErrorCode
.MP
)
29 stderr
.printf ("Error %s\n", mp_get_error ());
31 stderr
.printf ("Error %d\n", ret
);
34 public static int main (string[] args
)
36 /* Seed random number generator. */
37 var now
= new DateTime
.now_utc ();
38 Random
.set_seed (now
.get_microsecond ());
40 Intl
.setlocale (LocaleCategory
.ALL
, "");
42 result_serializer
= new
Serializer (DisplayFormat
.AUTOMATIC
, 10, 9);
44 var buffer
= new
char[1024];
48 var line
= stdin
.gets (buffer
);
51 if (line
== null || line
== "exit" || line
== "quit" || line
== "")
57 return Posix
.EXIT_SUCCESS
;