ruby-mpfr 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,13 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *.o
6
+ *.so
7
+ *.log
8
+ *~
9
+ \#*\#
10
+ ext/*/Makefile
11
+ ext/*/*/Makefile
12
+ doc
13
+ .yardoc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ruby-mpfr.gemspec
4
+ gemspec
@@ -1,7 +1,7 @@
1
1
  = ruby-mpfr
2
2
 
3
- * http://rubyforge.org/projects/ruby-mpfr/
4
- * http://gemcutter.org/gems/ruby-mpfr/
3
+ * https://github.com/ytaka/ruby-mpfr/
4
+ * http://rubygems.org/gems/ruby-mpfr/
5
5
 
6
6
  == Description:
7
7
 
@@ -34,21 +34,22 @@ The package of rubygems of ruby-mpfr is provided.
34
34
  You can install ruby-mpfr with the following command
35
35
  in the system satisfying the above requirements.
36
36
 
37
- $ sudo gem install ruby-mpfr
37
+ $ gem install ruby-mpfr
38
38
 
39
39
  == Related Software:
40
40
  These two gem packages uses ruby-mpfr.
41
41
 
42
- * ruby-mpc[http://gemcutter.org/gems/ruby-mpc/]: the arithmetic of complex numbers with multiprecision
43
- * ruby-mpfi[http://gemcutter.org/gems/ruby-mpfi/]: the interval arithmetic with multiprecision
42
+ * ruby-mpc[http://rubygems.org/gems/ruby-mpc/]: the arithmetic of complex numbers with multiprecision
43
+ * ruby-mpfi[http://rubygems.org/gems/ruby-mpfi/]: the interval arithmetic with multiprecision
44
44
 
45
45
  The following is an another multiple precision library which uses GMP.
46
- * http://gemcutter.org/gems/gmp
46
+
47
+ * http://rubygems.org/gems/gmp
47
48
 
48
49
  == License:
49
50
 
50
51
  ruby-mpfr
51
- Copyright (C) 2009 - 2010 Takayuki YAMAGUCHI
52
+ Copyright (C) 2009 Takayuki YAMAGUCHI
52
53
 
53
54
  This program is free software; you can redistribute it and/or modify it under
54
55
  the terms of the GNU Lesser General Public License as published by the Free
data/Rakefile CHANGED
@@ -1,30 +1,31 @@
1
- require 'rubygems'
2
- gem 'hoe', '>= 2.1.0'
3
- require 'hoe'
4
- require 'fileutils'
5
- require './lib/mpfr/version.rb'
6
- # require 'rake/clean'
1
+ require "bundler/gem_tasks"
7
2
 
8
- Hoe.plugin :newgem
9
- # Hoe.plugin :website
10
- # Hoe.plugin :cucumberfeatures
3
+ def each_extconf_directory(&block)
4
+ Dir.glob("ext/**/extconf.rb").each do |extconf|
5
+ cd File.dirname(extconf) do
6
+ yield
7
+ end
8
+ end
9
+ end
11
10
 
12
- # Generate all the Rake tasks
13
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
14
- $hoe = Hoe.spec 'ruby-mpfr' do
15
- self.developer 'Takayuki YAMAGUCHI', 'd@ytak.info'
16
- self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
17
- self.rubyforge_name = self.name # TODO this is default value
18
- # self.extra_deps = [['activesupport','>= 2.0.2']]
19
- self.spec_extras[:extensions] = ["ext/mpfr/extconf.rb", "ext/mpfr_matrix/mpfr/extconf.rb",
20
- "ext/gmp/mpfr/extconf.rb"]
21
- self.extra_rdoc_files << 'README.rdoc'
22
- self.extra_rdoc_files << 'Example.rdoc'
11
+ desc 'Compile extended library'
12
+ task 'ext:compile' do |t|
13
+ each_extconf_directory do
14
+ sh 'ruby extconf.rb' unless File.exist?('Makefile')
15
+ sh 'make'
16
+ end
23
17
  end
24
18
 
25
- # require 'newgem/tasks'
26
- Dir['tasks/**/*.rake'].each { |t| load t }
19
+ desc 'Clean'
20
+ task 'ext:clean' do |t|
21
+ each_extconf_directory do
22
+ sh 'make clean' if File.exist?('Makefile')
23
+ end
24
+ end
27
25
 
28
- # TODO - want other tests/tasks run by default? Add them to the list
29
- # remove_task :default
30
- # task :default => [:spec, :features]
26
+ desc 'Clean completely'
27
+ task 'ext:distclean' do |t|
28
+ each_extconf_directory do
29
+ sh 'make distclean' if File.exist?('Makefile')
30
+ end
31
+ end
@@ -12,7 +12,7 @@
12
12
 
13
13
  static ID eqq, to_s, new, class, method_defined, object_id, to_fr,
14
14
  id_rndn, id_rndz, id_rndu, id_rndd, id_rnda;
15
- static VALUE __mpfr_class__, __sym_to_s__, __sym_to_str__;
15
+ static VALUE __mpfr_class__, __sym_to_s__, __sym_to_str__, __mpfr_domain_error__;
16
16
 
17
17
  /* ------------------------------ Precision and Rounding Mode Start ------------------------------ */
18
18
  #define VALID_RND(rnd_mode) (rnd_mode >= MPFR_RNDN && rnd_mode < ((MPFR_RNDA)+1))
@@ -640,8 +640,9 @@ static VALUE r_mpfr_get_prec(VALUE self)
640
640
  static VALUE r_mpfr_set(int argc, VALUE *argv, VALUE self)
641
641
  {
642
642
  MPFR *ptr_self;
643
+ mp_rnd_t rnd;
643
644
  r_mpfr_get_struct(ptr_self, self);
644
- mp_rnd_t rnd = r_mpfr_rnd_from_optional_argument(1, 2, argc, argv);
645
+ rnd = r_mpfr_rnd_from_optional_argument(1, 2, argc, argv);
645
646
  r_mpfr_set_robj(ptr_self, argv[0], rnd);
646
647
  return self;
647
648
  }
@@ -653,8 +654,9 @@ static VALUE r_mpfr_set(int argc, VALUE *argv, VALUE self)
653
654
  static VALUE r_mpfr_set_fixnum_2exp(int argc, VALUE *argv, VALUE self)
654
655
  {
655
656
  MPFR *ptr_self;
657
+ mp_rnd_t rnd;
656
658
  r_mpfr_get_struct(ptr_self, self);
657
- mp_rnd_t rnd = r_mpfr_rnd_from_optional_argument(2, 3, argc, argv);
659
+ rnd = r_mpfr_rnd_from_optional_argument(2, 3, argc, argv);
658
660
  mpfr_set_si_2exp(ptr_self, NUM2INT(argv[0]), NUM2INT(argv[1]), rnd);
659
661
  return self;
660
662
  }
@@ -717,13 +719,14 @@ static VALUE r_mpfr_swap(VALUE self, VALUE other)
717
719
  static VALUE r_mpfr_to_strf(VALUE self, VALUE format_str)
718
720
  {
719
721
  MPFR *ptr_self;
722
+ char *format, *ret_str;
723
+ VALUE ret_val;
720
724
  r_mpfr_get_struct(ptr_self, self);
721
- char *format = StringValuePtr(format_str);
722
- char *ret_str;
725
+ format = StringValuePtr(format_str);
723
726
  if (!mpfr_asprintf(&ret_str, format, ptr_self)) {
724
727
  rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
725
728
  }
726
- VALUE ret_val = rb_str_new2(ret_str);
729
+ ret_val = rb_str_new2(ret_str);
727
730
  mpfr_free_str(ret_str);
728
731
  return ret_val;
729
732
  }
@@ -732,12 +735,13 @@ static VALUE r_mpfr_to_strf(VALUE self, VALUE format_str)
732
735
  static VALUE r_mpfr_to_s(VALUE self)
733
736
  {
734
737
  MPFR *ptr_self;
735
- r_mpfr_get_struct(ptr_self, self);
736
738
  char *ret_str;
739
+ VALUE ret_val;
740
+ r_mpfr_get_struct(ptr_self, self);
737
741
  if (!mpfr_asprintf(&ret_str, "%.Re", ptr_self)) {
738
742
  rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
739
743
  }
740
- VALUE ret_val = rb_str_new2(ret_str);
744
+ ret_val = rb_str_new2(ret_str);
741
745
  mpfr_free_str(ret_str);
742
746
  return ret_val;
743
747
  }
@@ -746,13 +750,14 @@ static VALUE r_mpfr_to_s(VALUE self)
746
750
  static VALUE r_mpfr_inspect(VALUE self)
747
751
  {
748
752
  MPFR *ptr_s;
749
- r_mpfr_get_struct(ptr_s, self);
750
753
  char *ret_str;
754
+ VALUE ret_val;
755
+ r_mpfr_get_struct(ptr_s, self);
751
756
  if (!mpfr_asprintf(&ret_str, "#<MPFR:%lx,'%0.Re',%d>", NUM2LONG(rb_funcall(self, object_id, 0)),
752
757
  ptr_s, mpfr_get_prec(ptr_s))) {
753
758
  rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
754
759
  }
755
- VALUE ret_val = rb_str_new2(ret_str);
760
+ ret_val = rb_str_new2(ret_str);
756
761
  mpfr_free_str(ret_str);
757
762
  return ret_val;
758
763
  }
@@ -774,18 +779,11 @@ static VALUE r_mpfr_get_d(int argc, VALUE *argv, VALUE self)
774
779
  static VALUE r_mpfr_get_d_2exp(int argc, VALUE *argv, VALUE self)
775
780
  {
776
781
  MPFR *ptr_self;
777
- r_mpfr_get_struct(ptr_self, self);
782
+ double ret_val1;
778
783
  long int ret_val2;
779
- double ret_val1 = mpfr_get_d_2exp(&ret_val2, ptr_self, r_mpfr_rnd_from_optional_argument(0, 1, argc, argv));
780
- return rb_ary_new3(2, rb_float_new(ret_val1), INT2NUM(ret_val2));
781
- }
782
-
783
- /* Return Fixnum object converted after rounding self with respect to rnd which is optional argument. */
784
- static VALUE r_mpfr_get_si(int argc, VALUE *argv, VALUE self)
785
- {
786
- MPFR *ptr_self;
787
784
  r_mpfr_get_struct(ptr_self, self);
788
- return INT2NUM(mpfr_get_si(ptr_self, r_mpfr_rnd_from_optional_argument(0, 1, argc, argv)));
785
+ ret_val1 = mpfr_get_d_2exp(&ret_val2, ptr_self, r_mpfr_rnd_from_optional_argument(0, 1, argc, argv));
786
+ return rb_ary_new3(2, rb_float_new(ret_val1), LONG2NUM(ret_val2));
789
787
  }
790
788
 
791
789
  /* Return Fixnum object which is nearest integer to self. */
@@ -793,7 +791,23 @@ static VALUE r_mpfr_round_to_i(VALUE self)
793
791
  {
794
792
  MPFR *ptr_self;
795
793
  r_mpfr_get_struct(ptr_self, self);
796
- return INT2NUM(mpfr_get_si(ptr_self, GMP_RNDN));
794
+ if (mpfr_fits_slong_p(ptr_self, GMP_RNDN)) {
795
+ return LONG2NUM(mpfr_get_si(ptr_self, GMP_RNDN));
796
+ } else if (mpfr_nan_p(ptr_self)) {
797
+ rb_raise(__mpfr_domain_error__, "Can not convert NaN to an integer");
798
+ } else {
799
+ MPFR *tmp_int;
800
+ char *tmp_str;
801
+ VALUE bignum;
802
+ r_mpfr_temp_alloc_init2(tmp_int, mpfr_get_prec(ptr_self));
803
+ mpfr_round(tmp_int, ptr_self);
804
+ if (!mpfr_asprintf(&tmp_str, "%Rf", tmp_int)) {
805
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
806
+ }
807
+ bignum = rb_cstr_to_inum(tmp_str, 10, false);
808
+ r_mpfr_temp_free(tmp_int);
809
+ return bignum;
810
+ }
797
811
  }
798
812
 
799
813
  /* Return Fixnum object which is the minimum integer over self. */
@@ -801,7 +815,23 @@ static VALUE r_mpfr_ceil_to_i(VALUE self)
801
815
  {
802
816
  MPFR *ptr_self;
803
817
  r_mpfr_get_struct(ptr_self, self);
804
- return INT2NUM(mpfr_get_si(ptr_self, GMP_RNDU));
818
+ if (mpfr_fits_slong_p(ptr_self, GMP_RNDU)) {
819
+ return LONG2NUM(mpfr_get_si(ptr_self, GMP_RNDU));
820
+ } else if (mpfr_nan_p(ptr_self)) {
821
+ rb_raise(__mpfr_domain_error__, "Can not convert NaN to an integer");
822
+ } else {
823
+ MPFR *tmp_int;
824
+ char *tmp_str;
825
+ VALUE bignum;
826
+ r_mpfr_temp_alloc_init2(tmp_int, mpfr_get_prec(ptr_self));
827
+ mpfr_ceil(tmp_int, ptr_self);
828
+ if (!mpfr_asprintf(&tmp_str, "%Rf", tmp_int)) {
829
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
830
+ }
831
+ bignum = rb_cstr_to_inum(tmp_str, 10, false);
832
+ r_mpfr_temp_free(tmp_int);
833
+ return bignum;
834
+ }
805
835
  }
806
836
 
807
837
  /* Return Fixnum object which is the maximum integer not over self. */
@@ -809,7 +839,23 @@ static VALUE r_mpfr_floor_to_i(VALUE self)
809
839
  {
810
840
  MPFR *ptr_self;
811
841
  r_mpfr_get_struct(ptr_self, self);
812
- return INT2NUM(mpfr_get_si(ptr_self, GMP_RNDD));
842
+ if (mpfr_fits_slong_p(ptr_self, GMP_RNDD)) {
843
+ return LONG2NUM(mpfr_get_si(ptr_self, GMP_RNDD));
844
+ } else if (mpfr_nan_p(ptr_self)) {
845
+ rb_raise(__mpfr_domain_error__, "Can not convert NaN to an integer");
846
+ } else {
847
+ MPFR *tmp_int;
848
+ char *tmp_str;
849
+ VALUE bignum;
850
+ r_mpfr_temp_alloc_init2(tmp_int, mpfr_get_prec(ptr_self));
851
+ mpfr_floor(tmp_int, ptr_self);
852
+ if (!mpfr_asprintf(&tmp_str, "%Rf", tmp_int)) {
853
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
854
+ }
855
+ bignum = rb_cstr_to_inum(tmp_str, 10, false);
856
+ r_mpfr_temp_free(tmp_int);
857
+ return bignum;
858
+ }
813
859
  }
814
860
 
815
861
  /* Return Fixnum object by truncating self. */
@@ -817,17 +863,35 @@ static VALUE r_mpfr_truncate_to_i(VALUE self)
817
863
  {
818
864
  MPFR *ptr_self;
819
865
  r_mpfr_get_struct(ptr_self, self);
820
- return INT2NUM(mpfr_get_si(ptr_self, GMP_RNDZ));
866
+ if (mpfr_fits_slong_p(ptr_self, GMP_RNDZ)) {
867
+ return LONG2NUM(mpfr_get_si(ptr_self, GMP_RNDZ));
868
+ } else if (mpfr_nan_p(ptr_self)) {
869
+ rb_raise(__mpfr_domain_error__, "Can not convert NaN to an integer");
870
+ } else {
871
+ MPFR *tmp_int;
872
+ char *tmp_str;
873
+ VALUE bignum;
874
+ r_mpfr_temp_alloc_init2(tmp_int, mpfr_get_prec(ptr_self));
875
+ mpfr_trunc(tmp_int, ptr_self);
876
+ if (!mpfr_asprintf(&tmp_str, "%Rf", tmp_int)) {
877
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
878
+ }
879
+ bignum = rb_cstr_to_inum(tmp_str, 10, false);
880
+ r_mpfr_temp_free(tmp_int);
881
+ return bignum;
882
+ }
821
883
  }
822
884
 
823
885
  /* Return array having String object meaning mantissa and Fixnum object meaning exponent. See MPFR reference for detail. */
824
886
  static VALUE r_mpfr_get_str(VALUE self)
825
887
  {
826
888
  MPFR *ptr_self;
827
- r_mpfr_get_struct(ptr_self, self);
828
889
  mp_exp_t e;
829
- char *str = mpfr_get_str(NULL, &e, 10, 0, ptr_self, GMP_RNDN);
830
- VALUE ret_str = rb_str_new2(str);
890
+ char *str;
891
+ VALUE ret_str;
892
+ r_mpfr_get_struct(ptr_self, self);
893
+ str = mpfr_get_str(NULL, &e, 10, 0, ptr_self, GMP_RNDN);
894
+ ret_str = rb_str_new2(str);
831
895
  mpfr_free_str(str);
832
896
  return rb_ary_new3(2, ret_str, INT2FIX((int)e));
833
897
  }
@@ -974,9 +1038,9 @@ static VALUE r_mpfr_neg(int argc, VALUE *argv, VALUE self)
974
1038
  {
975
1039
  mp_rnd_t rnd;
976
1040
  mp_prec_t prec;
977
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
978
1041
  MPFR *ptr_self, *ptr_return;
979
1042
  VALUE val_ret;
1043
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
980
1044
  r_mpfr_get_struct(ptr_self, self);
981
1045
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
982
1046
  mpfr_neg(ptr_return, ptr_self, rnd);
@@ -988,9 +1052,9 @@ static VALUE r_mpfr_abs(int argc, VALUE *argv, VALUE self)
988
1052
  {
989
1053
  mp_rnd_t rnd;
990
1054
  mp_prec_t prec;
991
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
992
1055
  MPFR *ptr_self, *ptr_return;
993
1056
  VALUE val_ret;
1057
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
994
1058
  r_mpfr_get_struct(ptr_self, self);
995
1059
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
996
1060
  mpfr_abs(ptr_return, ptr_self, rnd);
@@ -1006,10 +1070,11 @@ static VALUE r_mpfr_math_add(int argc, VALUE *argv, VALUE self)
1006
1070
  {
1007
1071
  mp_rnd_t rnd;
1008
1072
  mp_prec_t prec;
1009
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1010
1073
  MPFR *ptr_arg1, *ptr_arg2, *ptr_return;
1011
1074
  VALUE val_ret;
1012
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1075
+ volatile VALUE tmp_argv0;
1076
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1077
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1013
1078
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1014
1079
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1015
1080
 
@@ -1030,10 +1095,11 @@ static VALUE r_mpfr_math_sub(int argc, VALUE *argv, VALUE self)
1030
1095
  {
1031
1096
  mp_rnd_t rnd;
1032
1097
  mp_prec_t prec;
1033
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1034
1098
  MPFR *ptr_arg1, *ptr_arg2, *ptr_return;
1035
1099
  VALUE val_ret;
1036
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1100
+ volatile VALUE tmp_argv0;
1101
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1102
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1037
1103
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1038
1104
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1039
1105
 
@@ -1054,10 +1120,11 @@ static VALUE r_mpfr_math_mul(int argc, VALUE *argv, VALUE self)
1054
1120
  {
1055
1121
  mp_rnd_t rnd;
1056
1122
  mp_prec_t prec;
1057
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1058
1123
  MPFR *ptr_arg1, *ptr_arg2, *ptr_return;
1059
1124
  VALUE val_ret;
1060
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1125
+ volatile VALUE tmp_argv0;
1126
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1127
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1061
1128
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1062
1129
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1063
1130
 
@@ -1078,10 +1145,11 @@ static VALUE r_mpfr_math_div(int argc, VALUE *argv, VALUE self)
1078
1145
  {
1079
1146
  mp_rnd_t rnd;
1080
1147
  mp_prec_t prec;
1081
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1082
1148
  MPFR *ptr_arg1, *ptr_arg2, *ptr_return;
1083
1149
  VALUE val_ret;
1084
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1150
+ volatile VALUE tmp_argv0;
1151
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1152
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1085
1153
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1086
1154
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1087
1155
 
@@ -1102,10 +1170,11 @@ static VALUE r_mpfr_math_sqr(int argc, VALUE *argv, VALUE self)
1102
1170
  {
1103
1171
  mp_rnd_t rnd;
1104
1172
  mp_prec_t prec;
1105
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1106
1173
  MPFR *ptr_arg1, *ptr_return;
1107
1174
  VALUE val_ret;
1108
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1175
+ volatile VALUE tmp_argv0;
1176
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1177
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1109
1178
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1110
1179
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1111
1180
  mpfr_sqr(ptr_return, ptr_arg1, rnd);
@@ -1117,9 +1186,9 @@ static VALUE r_mpfr_math_sqrt(int argc, VALUE *argv, VALUE self)
1117
1186
  {
1118
1187
  mp_rnd_t rnd;
1119
1188
  mp_prec_t prec;
1120
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1121
1189
  MPFR *ptr_arg1, *ptr_return;
1122
1190
  VALUE val_ret;
1191
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1123
1192
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1124
1193
 
1125
1194
  if(TYPE(argv[0]) == T_FIXNUM){
@@ -1142,10 +1211,11 @@ static VALUE r_mpfr_math_rec_sqrt(int argc, VALUE *argv, VALUE self)
1142
1211
  {
1143
1212
  mp_rnd_t rnd;
1144
1213
  mp_prec_t prec;
1145
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1146
1214
  MPFR *ptr_arg1, *ptr_return;
1147
1215
  VALUE val_ret;
1148
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1216
+ volatile VALUE tmp_argv0;
1217
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1218
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1149
1219
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1150
1220
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1151
1221
  mpfr_rec_sqrt(ptr_return, ptr_arg1, rnd);
@@ -1157,10 +1227,11 @@ static VALUE r_mpfr_math_cbrt(int argc, VALUE *argv, VALUE self)
1157
1227
  {
1158
1228
  mp_rnd_t rnd;
1159
1229
  mp_prec_t prec;
1160
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1161
1230
  MPFR *ptr_arg1, *ptr_return;
1162
1231
  VALUE val_ret;
1163
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1232
+ volatile VALUE tmp_argv0;
1233
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1234
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1164
1235
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1165
1236
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1166
1237
  mpfr_cbrt(ptr_return, ptr_arg1, rnd);
@@ -1172,13 +1243,15 @@ static VALUE r_mpfr_math_root(int argc, VALUE *argv, VALUE self)
1172
1243
  {
1173
1244
  mp_rnd_t rnd;
1174
1245
  mp_prec_t prec;
1175
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1176
1246
  MPFR *ptr_arg1, *ptr_return;
1177
1247
  VALUE val_ret;
1178
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1248
+ volatile VALUE tmp_argv0;
1249
+ int root;
1250
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1251
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1179
1252
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1180
1253
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1181
- int root = NUM2INT(argv[1]);
1254
+ root = NUM2INT(argv[1]);
1182
1255
  if(root > 0){
1183
1256
  mpfr_root(ptr_return, ptr_arg1, root, rnd);
1184
1257
  }else{
@@ -1192,10 +1265,11 @@ static VALUE r_mpfr_math_pow(int argc, VALUE *argv, VALUE self)
1192
1265
  {
1193
1266
  mp_rnd_t rnd;
1194
1267
  mp_prec_t prec;
1195
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1196
1268
  MPFR *ptr_arg0, *ptr_arg1, *ptr_return;
1197
1269
  VALUE val_ret;
1198
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1270
+ volatile VALUE tmp_argv0;
1271
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1272
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1199
1273
  r_mpfr_get_struct(ptr_arg0, tmp_argv0);
1200
1274
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1201
1275
  if(TYPE(argv[1]) == T_FIXNUM){
@@ -1213,12 +1287,13 @@ static VALUE r_mpfr_math_dim(int argc, VALUE *argv, VALUE self)
1213
1287
  {
1214
1288
  mp_rnd_t rnd;
1215
1289
  mp_prec_t prec;
1216
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1217
1290
  MPFR *ptr_arg0, *ptr_arg1, *ptr_return;
1218
1291
  VALUE val_ret;
1219
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1292
+ volatile VALUE tmp_argv0, tmp_argv1;
1293
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1294
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1220
1295
  r_mpfr_get_struct(ptr_arg0, tmp_argv0);
1221
- volatile VALUE tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
1296
+ tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
1222
1297
  r_mpfr_get_struct(ptr_arg1, tmp_argv1);
1223
1298
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1224
1299
  mpfr_dim(ptr_return, ptr_arg0, ptr_arg1, rnd);
@@ -1230,10 +1305,11 @@ static VALUE r_mpfr_math_mul_2si(int argc, VALUE *argv, VALUE self)
1230
1305
  {
1231
1306
  mp_rnd_t rnd;
1232
1307
  mp_prec_t prec;
1233
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1234
1308
  MPFR *ptr_arg0, *ptr_return;
1235
1309
  VALUE val_ret;
1236
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1310
+ volatile VALUE tmp_argv0;
1311
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1312
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1237
1313
  r_mpfr_get_struct(ptr_arg0, tmp_argv0);
1238
1314
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1239
1315
  mpfr_mul_2si(ptr_return, ptr_arg0, NUM2INT(argv[1]), rnd);
@@ -1245,10 +1321,11 @@ static VALUE r_mpfr_math_div_2si(int argc, VALUE *argv, VALUE self)
1245
1321
  {
1246
1322
  mp_rnd_t rnd;
1247
1323
  mp_prec_t prec;
1248
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1249
1324
  MPFR *ptr_arg0, *ptr_return;
1250
1325
  VALUE val_ret;
1251
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1326
+ volatile VALUE tmp_argv0;
1327
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1328
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1252
1329
  r_mpfr_get_struct(ptr_arg0, tmp_argv0);
1253
1330
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1254
1331
  mpfr_div_2si(ptr_return, ptr_arg0, NUM2INT(argv[1]), rnd);
@@ -1263,8 +1340,8 @@ static VALUE r_mpfr_math_div_2si(int argc, VALUE *argv, VALUE self)
1263
1340
  static VALUE r_mpfr_cmp(VALUE self, VALUE other)
1264
1341
  {
1265
1342
  MPFR *ptr_self, *ptr_other;
1266
- r_mpfr_get_struct(ptr_self, self);
1267
1343
  int val_ret;
1344
+ r_mpfr_get_struct(ptr_self, self);
1268
1345
 
1269
1346
  if(MPFR_P(other)){
1270
1347
  r_mpfr_get_struct(ptr_other, other);
@@ -1287,9 +1364,10 @@ static VALUE r_mpfr_cmp(VALUE self, VALUE other)
1287
1364
  static VALUE r_mpfr_cmp_ui_2exp(VALUE self, VALUE other, VALUE exp)
1288
1365
  {
1289
1366
  MPFR *ptr_self;
1290
- r_mpfr_get_struct(ptr_self, self);
1291
1367
  VALUE val_ret;
1292
- int i = NUM2INT(other);
1368
+ int i;
1369
+ r_mpfr_get_struct(ptr_self, self);
1370
+ i = NUM2INT(other);
1293
1371
  if(i > 0){
1294
1372
  val_ret = INT2FIX(mpfr_cmp_ui_2exp(ptr_self, i, (mp_exp_t)NUM2INT(exp)));
1295
1373
  }else{
@@ -1310,8 +1388,9 @@ static VALUE r_mpfr_cmp_si_2exp(VALUE self, VALUE other, VALUE exp)
1310
1388
  static VALUE r_mpfr_cmpabs(VALUE self, VALUE other)
1311
1389
  {
1312
1390
  MPFR *ptr_self, *ptr_other;
1391
+ volatile VALUE tmp_other;
1313
1392
  r_mpfr_get_struct(ptr_self, self);
1314
- volatile VALUE tmp_other = r_mpfr_new_fr_obj(other);
1393
+ tmp_other = r_mpfr_new_fr_obj(other);
1315
1394
  r_mpfr_get_struct(ptr_other, tmp_other);
1316
1395
  return INT2FIX(mpfr_cmpabs(ptr_self, ptr_other));
1317
1396
  }
@@ -1392,8 +1471,9 @@ static VALUE r_mpfr_sgn(VALUE self)
1392
1471
  static VALUE r_mpfr_greater_p(VALUE self, VALUE other)
1393
1472
  {
1394
1473
  MPFR *ptr_self, *ptr_other;
1474
+ volatile VALUE tmp_other;
1395
1475
  r_mpfr_get_struct(ptr_self, self);
1396
- volatile VALUE tmp_other = r_mpfr_new_fr_obj(other);
1476
+ tmp_other = r_mpfr_new_fr_obj(other);
1397
1477
  r_mpfr_get_struct(ptr_other, tmp_other);
1398
1478
  return (mpfr_greater_p(ptr_self, ptr_other) != 0 ? Qtrue : Qfalse);
1399
1479
  }
@@ -1402,8 +1482,9 @@ static VALUE r_mpfr_greater_p(VALUE self, VALUE other)
1402
1482
  static VALUE r_mpfr_greaterequal_p(VALUE self, VALUE other)
1403
1483
  {
1404
1484
  MPFR *ptr_self, *ptr_other;
1485
+ volatile VALUE tmp_other;
1405
1486
  r_mpfr_get_struct(ptr_self, self);
1406
- volatile VALUE tmp_other = r_mpfr_new_fr_obj(other);
1487
+ tmp_other = r_mpfr_new_fr_obj(other);
1407
1488
  r_mpfr_get_struct(ptr_other, tmp_other);
1408
1489
  return (mpfr_greaterequal_p(ptr_self, ptr_other) != 0 ? Qtrue : Qfalse);
1409
1490
  }
@@ -1412,8 +1493,9 @@ static VALUE r_mpfr_greaterequal_p(VALUE self, VALUE other)
1412
1493
  static VALUE r_mpfr_less_p(VALUE self, VALUE other)
1413
1494
  {
1414
1495
  MPFR *ptr_self, *ptr_other;
1496
+ volatile VALUE tmp_other;
1415
1497
  r_mpfr_get_struct(ptr_self, self);
1416
- volatile VALUE tmp_other = r_mpfr_new_fr_obj(other);
1498
+ tmp_other = r_mpfr_new_fr_obj(other);
1417
1499
  r_mpfr_get_struct(ptr_other, tmp_other);
1418
1500
  return (mpfr_less_p(ptr_self, ptr_other) != 0 ? Qtrue : Qfalse);
1419
1501
  }
@@ -1422,8 +1504,9 @@ static VALUE r_mpfr_less_p(VALUE self, VALUE other)
1422
1504
  static VALUE r_mpfr_lessequal_p(VALUE self, VALUE other)
1423
1505
  {
1424
1506
  MPFR *ptr_self, *ptr_other;
1507
+ volatile VALUE tmp_other;
1425
1508
  r_mpfr_get_struct(ptr_self, self);
1426
- volatile VALUE tmp_other = r_mpfr_new_fr_obj(other);
1509
+ tmp_other = r_mpfr_new_fr_obj(other);
1427
1510
  r_mpfr_get_struct(ptr_other, tmp_other);
1428
1511
  return (mpfr_lessequal_p(ptr_self, ptr_other) != 0 ? Qtrue : Qfalse);
1429
1512
  }
@@ -1432,8 +1515,9 @@ static VALUE r_mpfr_lessequal_p(VALUE self, VALUE other)
1432
1515
  static VALUE r_mpfr_lessgreater_p(VALUE self, VALUE other)
1433
1516
  {
1434
1517
  MPFR *ptr_self, *ptr_other;
1518
+ volatile VALUE tmp_other;
1435
1519
  r_mpfr_get_struct(ptr_self, self);
1436
- volatile VALUE tmp_other = r_mpfr_new_fr_obj(other);
1520
+ tmp_other = r_mpfr_new_fr_obj(other);
1437
1521
  r_mpfr_get_struct(ptr_other, tmp_other);
1438
1522
  return (mpfr_lessgreater_p(ptr_self, ptr_other) != 0 ? Qtrue : Qfalse);
1439
1523
  }
@@ -1442,8 +1526,9 @@ static VALUE r_mpfr_lessgreater_p(VALUE self, VALUE other)
1442
1526
  static VALUE r_mpfr_equal_p(VALUE self, VALUE other)
1443
1527
  {
1444
1528
  MPFR *ptr_self, *ptr_other;
1529
+ volatile VALUE tmp_other;
1445
1530
  r_mpfr_get_struct(ptr_self, self);
1446
- volatile VALUE tmp_other = r_mpfr_new_fr_obj(other);
1531
+ tmp_other = r_mpfr_new_fr_obj(other);
1447
1532
  r_mpfr_get_struct(ptr_other, tmp_other);
1448
1533
  return (mpfr_equal_p(ptr_self, ptr_other) != 0 ? Qtrue : Qfalse);
1449
1534
  }
@@ -1452,8 +1537,9 @@ static VALUE r_mpfr_equal_p(VALUE self, VALUE other)
1452
1537
  static VALUE r_mpfr_unordered_p(VALUE self, VALUE other)
1453
1538
  {
1454
1539
  MPFR *ptr_self, *ptr_other;
1540
+ volatile VALUE tmp_other;
1455
1541
  r_mpfr_get_struct(ptr_self, self);
1456
- volatile VALUE tmp_other = r_mpfr_new_fr_obj(other);
1542
+ tmp_other = r_mpfr_new_fr_obj(other);
1457
1543
  r_mpfr_get_struct(ptr_other, tmp_other);
1458
1544
  return (mpfr_unordered_p(ptr_self, ptr_other) != 0 ? Qtrue : Qfalse);
1459
1545
  }
@@ -1467,9 +1553,9 @@ static VALUE r_mpfr_fr_rint(int argc, VALUE *argv, VALUE self)
1467
1553
  {
1468
1554
  mp_rnd_t rnd;
1469
1555
  mp_prec_t prec;
1470
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1471
1556
  MPFR *ptr_self, *ptr_return;
1472
1557
  VALUE val_ret;
1558
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1473
1559
  r_mpfr_get_struct(ptr_self, self);
1474
1560
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1475
1561
  mpfr_rint(ptr_return, ptr_self, rnd);
@@ -1529,9 +1615,9 @@ static VALUE r_mpfr_rint_ceil(int argc, VALUE *argv, VALUE self)
1529
1615
  {
1530
1616
  mp_rnd_t rnd;
1531
1617
  mp_prec_t prec;
1532
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1533
1618
  MPFR *ptr_self, *ptr_return;
1534
1619
  VALUE val_ret;
1620
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1535
1621
  r_mpfr_get_struct(ptr_self, self);
1536
1622
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1537
1623
  mpfr_rint_ceil(ptr_return, ptr_self, rnd);
@@ -1543,9 +1629,9 @@ static VALUE r_mpfr_rint_floor(int argc, VALUE *argv, VALUE self)
1543
1629
  {
1544
1630
  mp_rnd_t rnd;
1545
1631
  mp_prec_t prec;
1546
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1547
1632
  MPFR *ptr_self, *ptr_return;
1548
1633
  VALUE val_ret;
1634
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1549
1635
  r_mpfr_get_struct(ptr_self, self);
1550
1636
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1551
1637
  mpfr_rint_floor(ptr_return, ptr_self, rnd);
@@ -1557,9 +1643,9 @@ static VALUE r_mpfr_rint_round(int argc, VALUE *argv, VALUE self)
1557
1643
  {
1558
1644
  mp_rnd_t rnd;
1559
1645
  mp_prec_t prec;
1560
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1561
1646
  MPFR *ptr_self, *ptr_return;
1562
1647
  VALUE val_ret;
1648
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1563
1649
  r_mpfr_get_struct(ptr_self, self);
1564
1650
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1565
1651
  mpfr_rint_round(ptr_return, ptr_self, rnd);
@@ -1571,9 +1657,9 @@ static VALUE r_mpfr_rint_trunc(int argc, VALUE *argv, VALUE self)
1571
1657
  {
1572
1658
  mp_rnd_t rnd;
1573
1659
  mp_prec_t prec;
1574
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1575
1660
  MPFR *ptr_self, *ptr_return;
1576
1661
  VALUE val_ret;
1662
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1577
1663
  r_mpfr_get_struct(ptr_self, self);
1578
1664
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1579
1665
  mpfr_rint_trunc(ptr_return, ptr_self, rnd);
@@ -1585,9 +1671,9 @@ static VALUE r_mpfr_frac(int argc, VALUE *argv, VALUE self)
1585
1671
  {
1586
1672
  mp_rnd_t rnd;
1587
1673
  mp_prec_t prec;
1588
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1589
1674
  MPFR *ptr_self, *ptr_return;
1590
1675
  VALUE val_ret;
1676
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1591
1677
  r_mpfr_get_struct(ptr_self, self);
1592
1678
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1593
1679
  mpfr_frac(ptr_return, ptr_self, rnd);
@@ -1599,9 +1685,9 @@ static VALUE r_mpfr_modf(int argc, VALUE *argv, VALUE self)
1599
1685
  {
1600
1686
  mp_rnd_t rnd;
1601
1687
  mp_prec_t prec;
1602
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1603
1688
  MPFR *ptr_self, *ptr_return1, *ptr_return2;
1604
1689
  VALUE val_ret1, val_ret2;
1690
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1605
1691
  r_mpfr_get_struct(ptr_self, self);
1606
1692
  r_mpfr_make_struct_init2(val_ret1, ptr_return1, prec);
1607
1693
  r_mpfr_make_struct_init2(val_ret2, ptr_return2, prec);
@@ -1614,12 +1700,13 @@ static VALUE r_mpfr_fmod(int argc, VALUE *argv, VALUE self)
1614
1700
  {
1615
1701
  mp_rnd_t rnd;
1616
1702
  mp_prec_t prec;
1617
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1618
1703
  MPFR *ptr_self, *ptr_other, *ptr_return;
1619
1704
  VALUE val_ret;
1705
+ volatile VALUE tmp_argv0;
1706
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1620
1707
  r_mpfr_get_struct(ptr_self, self);
1621
1708
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1622
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1709
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1623
1710
  r_mpfr_get_struct(ptr_other, tmp_argv0);
1624
1711
  mpfr_fmod(ptr_return, ptr_self, ptr_other, rnd);
1625
1712
  return val_ret;
@@ -1630,12 +1717,13 @@ static VALUE r_mpfr_remainder(int argc, VALUE *argv, VALUE self)
1630
1717
  {
1631
1718
  mp_rnd_t rnd;
1632
1719
  mp_prec_t prec;
1633
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1634
1720
  MPFR *ptr_self, *ptr_other, *ptr_return;
1635
1721
  VALUE val_ret;
1722
+ volatile VALUE tmp_argv0;
1723
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1636
1724
  r_mpfr_get_struct(ptr_self, self);
1637
1725
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1638
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1726
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1639
1727
  r_mpfr_get_struct(ptr_other, tmp_argv0);
1640
1728
  mpfr_remainder(ptr_return, ptr_self, ptr_other, rnd);
1641
1729
  return val_ret;
@@ -1645,10 +1733,11 @@ static VALUE r_mpfr_remainder(int argc, VALUE *argv, VALUE self)
1645
1733
  static VALUE r_mpfr_remainder2(VALUE self, VALUE other)
1646
1734
  {
1647
1735
  MPFR *ptr_self, *ptr_other, *ptr_return;
1736
+ volatile VALUE tmp_other;
1648
1737
  VALUE val_ret;
1649
1738
  r_mpfr_get_struct(ptr_self, self);
1650
1739
  r_mpfr_make_struct_init(val_ret, ptr_return);
1651
- volatile VALUE tmp_other = r_mpfr_new_fr_obj(other);
1740
+ tmp_other = r_mpfr_new_fr_obj(other);
1652
1741
  r_mpfr_get_struct(ptr_other, tmp_other);
1653
1742
  mpfr_remainder(ptr_return, ptr_self, ptr_other, mpfr_get_default_rounding_mode());
1654
1743
  return val_ret;
@@ -1659,13 +1748,14 @@ static VALUE r_mpfr_remquo(int argc, VALUE *argv, VALUE self)
1659
1748
  {
1660
1749
  mp_rnd_t rnd;
1661
1750
  mp_prec_t prec;
1662
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1663
1751
  MPFR *ptr_self, *ptr_other, *ptr_return;
1664
1752
  VALUE val_ret;
1665
1753
  long q;
1754
+ volatile VALUE tmp_argv0;
1755
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1666
1756
  r_mpfr_get_struct(ptr_self, self);
1667
1757
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1668
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1758
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1669
1759
  r_mpfr_get_struct(ptr_other, tmp_argv0);
1670
1760
  mpfr_remquo(ptr_return, &q, ptr_self, ptr_other, rnd);
1671
1761
  return rb_ary_new3(2, val_ret, LONG2FIX(q));
@@ -1687,8 +1777,9 @@ static VALUE r_mpfr_integer_p(VALUE self)
1687
1777
  static VALUE r_mpfr_nexttoward(VALUE self, VALUE other)
1688
1778
  {
1689
1779
  MPFR *ptr_self, *ptr_other;
1780
+ volatile VALUE tmp_other;
1690
1781
  r_mpfr_get_struct(ptr_self, self);
1691
- volatile VALUE tmp_other = r_mpfr_new_fr_obj(other);
1782
+ tmp_other = r_mpfr_new_fr_obj(other);
1692
1783
  r_mpfr_get_struct(ptr_other, tmp_other);
1693
1784
  mpfr_nexttoward(ptr_self, ptr_other);
1694
1785
  return self;
@@ -1728,8 +1819,9 @@ static VALUE r_mpfr_get_exp(VALUE self)
1728
1819
  static VALUE r_mpfr_set_exp(VALUE self, VALUE arg_exp)
1729
1820
  {
1730
1821
  MPFR *ptr_self;
1822
+ mp_exp_t exp;
1731
1823
  r_mpfr_get_struct(ptr_self, self);
1732
- mp_exp_t exp = NUM2INT(arg_exp);
1824
+ exp = NUM2INT(arg_exp);
1733
1825
  mpfr_set_exp(ptr_self, exp);
1734
1826
  return self;
1735
1827
  }
@@ -1747,12 +1839,13 @@ static VALUE r_mpfr_setsign(int argc, VALUE *argv, VALUE self)
1747
1839
  {
1748
1840
  mp_rnd_t rnd;
1749
1841
  mp_prec_t prec;
1750
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1751
1842
  MPFR *ptr_self, *ptr_return;
1752
1843
  VALUE val_ret;
1844
+ int s;
1845
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1753
1846
  r_mpfr_get_struct(ptr_self, self);
1754
1847
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1755
- int s = NUM2INT(argv[0]);
1848
+ s = NUM2INT(argv[0]);
1756
1849
  mpfr_setsign(ptr_return, ptr_self, s, rnd);
1757
1850
  return val_ret;
1758
1851
  }
@@ -1762,12 +1855,13 @@ static VALUE r_mpfr_copysign(int argc, VALUE *argv, VALUE self)
1762
1855
  {
1763
1856
  mp_rnd_t rnd;
1764
1857
  mp_prec_t prec;
1765
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1766
1858
  MPFR *ptr_self, *ptr_return, *ptr_arg;
1767
1859
  VALUE val_ret;
1860
+ volatile VALUE tmp_argv0;
1861
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
1768
1862
  r_mpfr_get_struct(ptr_self, self);
1769
1863
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1770
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1864
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1771
1865
  r_mpfr_get_struct(ptr_arg, tmp_argv0);
1772
1866
  mpfr_copysign(ptr_return, ptr_self, ptr_arg, rnd);
1773
1867
  return val_ret;
@@ -1782,9 +1876,9 @@ static VALUE r_mpfr_prec_round(int argc, VALUE *argv, VALUE self)
1782
1876
  {
1783
1877
  mp_rnd_t rnd;
1784
1878
  mp_prec_t prec;
1785
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1786
1879
  MPFR *ptr_self, *ptr_return;
1787
1880
  VALUE val_ret;
1881
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1788
1882
  r_mpfr_get_struct(ptr_self, self);
1789
1883
  r_mpfr_make_struct_init2(val_ret, ptr_return, mpfr_get_prec(ptr_self));
1790
1884
  mpfr_set(ptr_return, ptr_self, mpfr_get_default_prec());
@@ -1797,8 +1891,8 @@ static VALUE r_mpfr_prec_round2(int argc, VALUE *argv, VALUE self)
1797
1891
  {
1798
1892
  mp_rnd_t rnd;
1799
1893
  mp_prec_t prec;
1800
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1801
1894
  MPFR *ptr_self;
1895
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
1802
1896
  r_mpfr_get_struct(ptr_self, self);
1803
1897
  mpfr_prec_round(ptr_self, prec, rnd);
1804
1898
  return self;
@@ -1849,10 +1943,11 @@ static VALUE r_mpfr_math_log(int argc, VALUE *argv, VALUE self)
1849
1943
  {
1850
1944
  mp_rnd_t rnd;
1851
1945
  mp_prec_t prec;
1852
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1853
1946
  MPFR *ptr_arg1, *ptr_return;
1854
1947
  VALUE val_ret;
1855
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1948
+ volatile VALUE tmp_argv0;
1949
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1950
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1856
1951
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1857
1952
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1858
1953
  r_mpfr_set_special_func_state(mpfr_log(ptr_return, ptr_arg1, rnd));
@@ -1864,10 +1959,11 @@ static VALUE r_mpfr_math_log2(int argc, VALUE *argv, VALUE self)
1864
1959
  {
1865
1960
  mp_rnd_t rnd;
1866
1961
  mp_prec_t prec;
1867
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1868
1962
  MPFR *ptr_arg1, *ptr_return;
1869
1963
  VALUE val_ret;
1870
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1964
+ volatile VALUE tmp_argv0;
1965
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1966
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1871
1967
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1872
1968
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1873
1969
  r_mpfr_set_special_func_state(mpfr_log2(ptr_return, ptr_arg1, rnd));
@@ -1879,10 +1975,11 @@ static VALUE r_mpfr_math_log10(int argc, VALUE *argv, VALUE self)
1879
1975
  {
1880
1976
  mp_rnd_t rnd;
1881
1977
  mp_prec_t prec;
1882
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1883
1978
  MPFR *ptr_arg1, *ptr_return;
1884
1979
  VALUE val_ret;
1885
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1980
+ volatile VALUE tmp_argv0;
1981
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1982
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1886
1983
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1887
1984
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1888
1985
  r_mpfr_set_special_func_state(mpfr_log10(ptr_return, ptr_arg1, rnd));
@@ -1894,10 +1991,11 @@ static VALUE r_mpfr_math_exp(int argc, VALUE *argv, VALUE self)
1894
1991
  {
1895
1992
  mp_rnd_t rnd;
1896
1993
  mp_prec_t prec;
1897
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1898
1994
  MPFR *ptr_arg1, *ptr_return;
1899
1995
  VALUE val_ret;
1900
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1996
+ volatile VALUE tmp_argv0;
1997
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1998
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1901
1999
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1902
2000
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1903
2001
  r_mpfr_set_special_func_state(mpfr_exp(ptr_return, ptr_arg1, rnd));
@@ -1909,10 +2007,11 @@ static VALUE r_mpfr_math_exp2(int argc, VALUE *argv, VALUE self)
1909
2007
  {
1910
2008
  mp_rnd_t rnd;
1911
2009
  mp_prec_t prec;
1912
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1913
2010
  MPFR *ptr_arg1, *ptr_return;
1914
2011
  VALUE val_ret;
1915
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2012
+ volatile VALUE tmp_argv0;
2013
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2014
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1916
2015
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1917
2016
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1918
2017
  r_mpfr_set_special_func_state(mpfr_exp2(ptr_return, ptr_arg1, rnd));
@@ -1924,10 +2023,11 @@ static VALUE r_mpfr_math_exp10(int argc, VALUE *argv, VALUE self)
1924
2023
  {
1925
2024
  mp_rnd_t rnd;
1926
2025
  mp_prec_t prec;
1927
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1928
2026
  MPFR *ptr_arg1, *ptr_return;
1929
2027
  VALUE val_ret;
1930
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2028
+ volatile VALUE tmp_argv0;
2029
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2030
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1931
2031
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1932
2032
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1933
2033
  r_mpfr_set_special_func_state(mpfr_exp10(ptr_return, ptr_arg1, rnd));
@@ -1939,10 +2039,11 @@ static VALUE r_mpfr_math_cos(int argc, VALUE *argv, VALUE self)
1939
2039
  {
1940
2040
  mp_rnd_t rnd;
1941
2041
  mp_prec_t prec;
1942
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1943
2042
  MPFR *ptr_arg1, *ptr_return;
1944
2043
  VALUE val_ret;
1945
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2044
+ volatile VALUE tmp_argv0;
2045
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2046
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1946
2047
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1947
2048
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1948
2049
  r_mpfr_set_special_func_state(mpfr_cos(ptr_return, ptr_arg1, rnd));
@@ -1954,10 +2055,11 @@ static VALUE r_mpfr_math_sin(int argc, VALUE *argv, VALUE self)
1954
2055
  {
1955
2056
  mp_rnd_t rnd;
1956
2057
  mp_prec_t prec;
1957
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1958
2058
  MPFR *ptr_arg1, *ptr_return;
1959
2059
  VALUE val_ret;
1960
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2060
+ volatile VALUE tmp_argv0;
2061
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2062
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1961
2063
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1962
2064
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1963
2065
  r_mpfr_set_special_func_state(mpfr_sin(ptr_return, ptr_arg1, rnd));
@@ -1969,10 +2071,11 @@ static VALUE r_mpfr_math_tan(int argc, VALUE *argv, VALUE self)
1969
2071
  {
1970
2072
  mp_rnd_t rnd;
1971
2073
  mp_prec_t prec;
1972
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1973
2074
  MPFR *ptr_arg1, *ptr_return;
1974
2075
  VALUE val_ret;
1975
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2076
+ volatile VALUE tmp_argv0;
2077
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2078
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1976
2079
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1977
2080
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1978
2081
  r_mpfr_set_special_func_state(mpfr_tan(ptr_return, ptr_arg1, rnd));
@@ -1984,10 +2087,11 @@ static VALUE r_mpfr_math_sec(int argc, VALUE *argv, VALUE self)
1984
2087
  {
1985
2088
  mp_rnd_t rnd;
1986
2089
  mp_prec_t prec;
1987
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
1988
2090
  MPFR *ptr_arg1, *ptr_return;
1989
2091
  VALUE val_ret;
1990
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2092
+ volatile VALUE tmp_argv0;
2093
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2094
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
1991
2095
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
1992
2096
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
1993
2097
  r_mpfr_set_special_func_state(mpfr_sec(ptr_return, ptr_arg1, rnd));
@@ -1999,10 +2103,11 @@ static VALUE r_mpfr_math_csc(int argc, VALUE *argv, VALUE self)
1999
2103
  {
2000
2104
  mp_rnd_t rnd;
2001
2105
  mp_prec_t prec;
2002
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2003
2106
  MPFR *ptr_arg1, *ptr_return;
2004
2107
  VALUE val_ret;
2005
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2108
+ volatile VALUE tmp_argv0;
2109
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2110
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2006
2111
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2007
2112
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2008
2113
  r_mpfr_set_special_func_state(mpfr_csc(ptr_return, ptr_arg1, rnd));
@@ -2014,10 +2119,11 @@ static VALUE r_mpfr_math_cot(int argc, VALUE *argv, VALUE self)
2014
2119
  {
2015
2120
  mp_rnd_t rnd;
2016
2121
  mp_prec_t prec;
2017
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2018
2122
  MPFR *ptr_arg1, *ptr_return;
2019
2123
  VALUE val_ret;
2020
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2124
+ volatile VALUE tmp_argv0;
2125
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2126
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2021
2127
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2022
2128
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2023
2129
  r_mpfr_set_special_func_state(mpfr_cot(ptr_return, ptr_arg1, rnd));
@@ -2029,10 +2135,11 @@ static VALUE r_mpfr_math_sin_cos(int argc, VALUE *argv, VALUE self)
2029
2135
  {
2030
2136
  mp_rnd_t rnd;
2031
2137
  mp_prec_t prec;
2032
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2033
2138
  MPFR *ptr_arg1, *ptr_return1, *ptr_return2;
2034
2139
  VALUE val_ret1, val_ret2;
2035
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2140
+ volatile VALUE tmp_argv0;
2141
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2142
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2036
2143
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2037
2144
  r_mpfr_make_struct_init2(val_ret1, ptr_return1, prec);
2038
2145
  r_mpfr_make_struct_init2(val_ret2, ptr_return2, prec);
@@ -2045,10 +2152,11 @@ static VALUE r_mpfr_math_acos(int argc, VALUE *argv, VALUE self)
2045
2152
  {
2046
2153
  mp_rnd_t rnd;
2047
2154
  mp_prec_t prec;
2048
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2049
2155
  MPFR *ptr_arg1, *ptr_return;
2050
2156
  VALUE val_ret;
2051
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2157
+ volatile VALUE tmp_argv0;
2158
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2159
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2052
2160
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2053
2161
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2054
2162
  r_mpfr_set_special_func_state(mpfr_acos(ptr_return, ptr_arg1, rnd));
@@ -2060,10 +2168,11 @@ static VALUE r_mpfr_math_asin(int argc, VALUE *argv, VALUE self)
2060
2168
  {
2061
2169
  mp_rnd_t rnd;
2062
2170
  mp_prec_t prec;
2063
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2064
2171
  MPFR *ptr_arg1, *ptr_return;
2065
2172
  VALUE val_ret;
2066
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2173
+ volatile VALUE tmp_argv0;
2174
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2175
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2067
2176
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2068
2177
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2069
2178
  r_mpfr_set_special_func_state(mpfr_asin(ptr_return, ptr_arg1, rnd));
@@ -2075,10 +2184,11 @@ static VALUE r_mpfr_math_atan(int argc, VALUE *argv, VALUE self)
2075
2184
  {
2076
2185
  mp_rnd_t rnd;
2077
2186
  mp_prec_t prec;
2078
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2079
2187
  MPFR *ptr_arg1, *ptr_return;
2080
2188
  VALUE val_ret;
2081
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2189
+ volatile VALUE tmp_argv0;
2190
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2191
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2082
2192
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2083
2193
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2084
2194
  r_mpfr_set_special_func_state(mpfr_atan(ptr_return, ptr_arg1, rnd));
@@ -2090,12 +2200,13 @@ static VALUE r_mpfr_math_atan2(int argc, VALUE *argv, VALUE self)
2090
2200
  {
2091
2201
  mp_rnd_t rnd;
2092
2202
  mp_prec_t prec;
2093
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
2094
2203
  MPFR *ptr_arg0, *ptr_arg1, *ptr_return;
2095
2204
  VALUE val_ret;
2096
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2205
+ volatile VALUE tmp_argv0, tmp_argv1;
2206
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
2207
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2097
2208
  r_mpfr_get_struct(ptr_arg0, tmp_argv0);
2098
- volatile VALUE tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
2209
+ tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
2099
2210
  r_mpfr_get_struct(ptr_arg1, tmp_argv1);
2100
2211
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2101
2212
  r_mpfr_set_special_func_state(mpfr_atan2(ptr_return, ptr_arg0, ptr_arg1, rnd));
@@ -2107,10 +2218,11 @@ static VALUE r_mpfr_math_cosh(int argc, VALUE *argv, VALUE self)
2107
2218
  {
2108
2219
  mp_rnd_t rnd;
2109
2220
  mp_prec_t prec;
2110
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2111
2221
  MPFR *ptr_arg1, *ptr_return;
2112
2222
  VALUE val_ret;
2113
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2223
+ volatile VALUE tmp_argv0;
2224
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2225
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2114
2226
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2115
2227
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2116
2228
  r_mpfr_set_special_func_state(mpfr_cosh(ptr_return, ptr_arg1, rnd));
@@ -2122,10 +2234,11 @@ static VALUE r_mpfr_math_sinh(int argc, VALUE *argv, VALUE self)
2122
2234
  {
2123
2235
  mp_rnd_t rnd;
2124
2236
  mp_prec_t prec;
2125
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2126
2237
  MPFR *ptr_arg1, *ptr_return;
2127
2238
  VALUE val_ret;
2128
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2239
+ volatile VALUE tmp_argv0;
2240
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2241
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2129
2242
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2130
2243
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2131
2244
  r_mpfr_set_special_func_state(mpfr_sinh(ptr_return, ptr_arg1, rnd));
@@ -2137,10 +2250,11 @@ static VALUE r_mpfr_math_tanh(int argc, VALUE *argv, VALUE self)
2137
2250
  {
2138
2251
  mp_rnd_t rnd;
2139
2252
  mp_prec_t prec;
2140
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2141
2253
  MPFR *ptr_arg1, *ptr_return;
2142
2254
  VALUE val_ret;
2143
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2255
+ volatile VALUE tmp_argv0;
2256
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2257
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2144
2258
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2145
2259
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2146
2260
  r_mpfr_set_special_func_state(mpfr_tanh(ptr_return, ptr_arg1, rnd));
@@ -2152,10 +2266,11 @@ static VALUE r_mpfr_math_sinh_cosh(int argc, VALUE *argv, VALUE self)
2152
2266
  {
2153
2267
  mp_rnd_t rnd;
2154
2268
  mp_prec_t prec;
2155
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2156
2269
  MPFR *ptr_arg1, *ptr_return1, *ptr_return2;
2157
2270
  VALUE val_ret1, val_ret2;
2158
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2271
+ volatile VALUE tmp_argv0;
2272
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2273
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2159
2274
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2160
2275
  r_mpfr_make_struct_init2(val_ret1, ptr_return1, prec);
2161
2276
  r_mpfr_make_struct_init2(val_ret2, ptr_return2, prec);
@@ -2168,10 +2283,11 @@ static VALUE r_mpfr_math_sech(int argc, VALUE *argv, VALUE self)
2168
2283
  {
2169
2284
  mp_rnd_t rnd;
2170
2285
  mp_prec_t prec;
2171
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2172
2286
  MPFR *ptr_arg1, *ptr_return;
2173
2287
  VALUE val_ret;
2174
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2288
+ volatile VALUE tmp_argv0;
2289
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2290
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2175
2291
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2176
2292
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2177
2293
  r_mpfr_set_special_func_state(mpfr_sech(ptr_return, ptr_arg1, rnd));
@@ -2183,10 +2299,11 @@ static VALUE r_mpfr_math_csch(int argc, VALUE *argv, VALUE self)
2183
2299
  {
2184
2300
  mp_rnd_t rnd;
2185
2301
  mp_prec_t prec;
2186
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2187
2302
  MPFR *ptr_arg1, *ptr_return;
2188
2303
  VALUE val_ret;
2189
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2304
+ volatile VALUE tmp_argv0;
2305
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2306
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2190
2307
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2191
2308
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2192
2309
  r_mpfr_set_special_func_state(mpfr_csch(ptr_return, ptr_arg1, rnd));
@@ -2198,10 +2315,11 @@ static VALUE r_mpfr_math_coth(int argc, VALUE *argv, VALUE self)
2198
2315
  {
2199
2316
  mp_rnd_t rnd;
2200
2317
  mp_prec_t prec;
2201
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2202
2318
  MPFR *ptr_arg1, *ptr_return;
2203
2319
  VALUE val_ret;
2204
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2320
+ volatile VALUE tmp_argv0;
2321
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2322
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2205
2323
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2206
2324
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2207
2325
  r_mpfr_set_special_func_state(mpfr_coth(ptr_return, ptr_arg1, rnd));
@@ -2213,10 +2331,11 @@ static VALUE r_mpfr_math_acosh(int argc, VALUE *argv, VALUE self)
2213
2331
  {
2214
2332
  mp_rnd_t rnd;
2215
2333
  mp_prec_t prec;
2216
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2217
2334
  MPFR *ptr_arg1, *ptr_return;
2218
2335
  VALUE val_ret;
2219
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2336
+ volatile VALUE tmp_argv0;
2337
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2338
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2220
2339
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2221
2340
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2222
2341
  r_mpfr_set_special_func_state(mpfr_acosh(ptr_return, ptr_arg1, rnd));
@@ -2228,10 +2347,11 @@ static VALUE r_mpfr_math_asinh(int argc, VALUE *argv, VALUE self)
2228
2347
  {
2229
2348
  mp_rnd_t rnd;
2230
2349
  mp_prec_t prec;
2231
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2232
2350
  MPFR *ptr_arg1, *ptr_return;
2233
2351
  VALUE val_ret;
2234
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2352
+ volatile VALUE tmp_argv0;
2353
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2354
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2235
2355
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2236
2356
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2237
2357
  r_mpfr_set_special_func_state(mpfr_asinh(ptr_return, ptr_arg1, rnd));
@@ -2243,10 +2363,11 @@ static VALUE r_mpfr_math_atanh(int argc, VALUE *argv, VALUE self)
2243
2363
  {
2244
2364
  mp_rnd_t rnd;
2245
2365
  mp_prec_t prec;
2246
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2247
2366
  MPFR *ptr_arg1, *ptr_return;
2248
2367
  VALUE val_ret;
2249
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2368
+ volatile VALUE tmp_argv0;
2369
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2370
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2250
2371
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2251
2372
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2252
2373
  r_mpfr_set_special_func_state(mpfr_atanh(ptr_return, ptr_arg1, rnd));
@@ -2258,11 +2379,12 @@ static VALUE r_mpfr_math_fac_ui(int argc, VALUE *argv, VALUE self)
2258
2379
  {
2259
2380
  mp_rnd_t rnd;
2260
2381
  mp_prec_t prec;
2261
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2262
2382
  MPFR *ptr_return;
2263
2383
  VALUE val_ret;
2384
+ int num;
2385
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2264
2386
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2265
- int num = NUM2INT(argv[0]);
2387
+ num = NUM2INT(argv[0]);
2266
2388
  if(num >= 0){
2267
2389
  r_mpfr_set_special_func_state(mpfr_fac_ui(ptr_return, num, rnd));
2268
2390
  }else{
@@ -2276,10 +2398,11 @@ static VALUE r_mpfr_math_log1p(int argc, VALUE *argv, VALUE self)
2276
2398
  {
2277
2399
  mp_rnd_t rnd;
2278
2400
  mp_prec_t prec;
2279
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2280
2401
  MPFR *ptr_arg1, *ptr_return;
2281
2402
  VALUE val_ret;
2282
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2403
+ volatile VALUE tmp_argv0;
2404
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2405
+ tmp_argv0= r_mpfr_new_fr_obj(argv[0]);
2283
2406
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2284
2407
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2285
2408
  r_mpfr_set_special_func_state(mpfr_log1p(ptr_return, ptr_arg1, rnd));
@@ -2291,10 +2414,11 @@ static VALUE r_mpfr_math_expm1(int argc, VALUE *argv, VALUE self)
2291
2414
  {
2292
2415
  mp_rnd_t rnd;
2293
2416
  mp_prec_t prec;
2294
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2295
2417
  MPFR *ptr_arg1, *ptr_return;
2296
2418
  VALUE val_ret;
2297
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2419
+ volatile VALUE tmp_argv0;
2420
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2421
+ tmp_argv0= r_mpfr_new_fr_obj(argv[0]);
2298
2422
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2299
2423
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2300
2424
  r_mpfr_set_special_func_state(mpfr_expm1(ptr_return, ptr_arg1, rnd));
@@ -2306,10 +2430,11 @@ static VALUE r_mpfr_math_eint(int argc, VALUE *argv, VALUE self)
2306
2430
  {
2307
2431
  mp_rnd_t rnd;
2308
2432
  mp_prec_t prec;
2309
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2310
2433
  MPFR *ptr_arg1, *ptr_return;
2311
2434
  VALUE val_ret;
2312
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2435
+ volatile VALUE tmp_argv0;
2436
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2437
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2313
2438
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2314
2439
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2315
2440
  r_mpfr_set_special_func_state(mpfr_eint(ptr_return, ptr_arg1, rnd));
@@ -2321,10 +2446,11 @@ static VALUE r_mpfr_math_li2(int argc, VALUE *argv, VALUE self)
2321
2446
  {
2322
2447
  mp_rnd_t rnd;
2323
2448
  mp_prec_t prec;
2324
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2325
2449
  MPFR *ptr_arg1, *ptr_return;
2326
2450
  VALUE val_ret;
2327
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2451
+ volatile VALUE tmp_argv0;
2452
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2453
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2328
2454
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2329
2455
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2330
2456
  r_mpfr_set_special_func_state(mpfr_li2(ptr_return, ptr_arg1, rnd));
@@ -2336,10 +2462,11 @@ static VALUE r_mpfr_math_gamma(int argc, VALUE *argv, VALUE self)
2336
2462
  {
2337
2463
  mp_rnd_t rnd;
2338
2464
  mp_prec_t prec;
2339
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2340
2465
  MPFR *ptr_arg1, *ptr_return;
2341
2466
  VALUE val_ret;
2342
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2467
+ volatile VALUE tmp_argv0;
2468
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2469
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2343
2470
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2344
2471
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2345
2472
  r_mpfr_set_special_func_state(mpfr_gamma(ptr_return, ptr_arg1, rnd));
@@ -2351,10 +2478,11 @@ static VALUE r_mpfr_math_lngamma(int argc, VALUE *argv, VALUE self)
2351
2478
  {
2352
2479
  mp_rnd_t rnd;
2353
2480
  mp_prec_t prec;
2354
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2355
2481
  MPFR *ptr_arg1, *ptr_return;
2356
2482
  VALUE val_ret;
2357
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2483
+ volatile VALUE tmp_argv0;
2484
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2485
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2358
2486
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2359
2487
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2360
2488
  r_mpfr_set_special_func_state(mpfr_lngamma(ptr_return, ptr_arg1, rnd));
@@ -2366,11 +2494,12 @@ static VALUE r_mpfr_math_lgamma(int argc, VALUE *argv, VALUE self)
2366
2494
  {
2367
2495
  mp_rnd_t rnd;
2368
2496
  mp_prec_t prec;
2369
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2370
2497
  MPFR *ptr_arg1, *ptr_return;
2371
2498
  VALUE val_ret;
2372
2499
  int singp;
2373
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2500
+ volatile VALUE tmp_argv0;
2501
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2502
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2374
2503
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2375
2504
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2376
2505
  r_mpfr_set_special_func_state(mpfr_lgamma(ptr_return, &singp, ptr_arg1, rnd));
@@ -2382,10 +2511,11 @@ static VALUE r_mpfr_math_digamma(int argc, VALUE *argv, VALUE self)
2382
2511
  {
2383
2512
  mp_rnd_t rnd;
2384
2513
  mp_prec_t prec;
2385
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2386
2514
  MPFR *ptr_arg1, *ptr_return;
2387
2515
  VALUE val_ret;
2388
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2516
+ volatile VALUE tmp_argv0;
2517
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2518
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2389
2519
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2390
2520
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2391
2521
  r_mpfr_set_special_func_state(mpfr_digamma(ptr_return, ptr_arg1, rnd));
@@ -2397,9 +2527,9 @@ static VALUE r_mpfr_math_zeta(int argc, VALUE *argv, VALUE self)
2397
2527
  {
2398
2528
  mp_rnd_t rnd;
2399
2529
  mp_prec_t prec;
2400
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2401
2530
  MPFR *ptr_arg1, *ptr_return;
2402
2531
  VALUE val_ret;
2532
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2403
2533
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2404
2534
  if(TYPE(argv[0]) == T_FIXNUM){
2405
2535
  int num = FIX2LONG(argv[0]);
@@ -2420,10 +2550,11 @@ static VALUE r_mpfr_math_erf(int argc, VALUE *argv, VALUE self)
2420
2550
  {
2421
2551
  mp_rnd_t rnd;
2422
2552
  mp_prec_t prec;
2423
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2424
2553
  MPFR *ptr_arg1, *ptr_return;
2425
2554
  VALUE val_ret;
2426
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2555
+ volatile VALUE tmp_argv0;
2556
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2557
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2427
2558
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2428
2559
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2429
2560
  r_mpfr_set_special_func_state(mpfr_erf(ptr_return, ptr_arg1, rnd));
@@ -2435,10 +2566,11 @@ static VALUE r_mpfr_math_erfc(int argc, VALUE *argv, VALUE self)
2435
2566
  {
2436
2567
  mp_rnd_t rnd;
2437
2568
  mp_prec_t prec;
2438
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2439
2569
  MPFR *ptr_arg1, *ptr_return;
2440
2570
  VALUE val_ret;
2441
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2571
+ volatile VALUE tmp_argv0;
2572
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2573
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2442
2574
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2443
2575
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2444
2576
  r_mpfr_set_special_func_state(mpfr_erfc(ptr_return, ptr_arg1, rnd));
@@ -2450,10 +2582,11 @@ static VALUE r_mpfr_math_j0(int argc, VALUE *argv, VALUE self)
2450
2582
  {
2451
2583
  mp_rnd_t rnd;
2452
2584
  mp_prec_t prec;
2453
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2454
2585
  MPFR *ptr_arg1, *ptr_return;
2455
2586
  VALUE val_ret;
2456
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2587
+ volatile VALUE tmp_argv0;
2588
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2589
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2457
2590
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2458
2591
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2459
2592
  r_mpfr_set_special_func_state(mpfr_j0(ptr_return, ptr_arg1, rnd));
@@ -2465,10 +2598,11 @@ static VALUE r_mpfr_math_j1(int argc, VALUE *argv, VALUE self)
2465
2598
  {
2466
2599
  mp_rnd_t rnd;
2467
2600
  mp_prec_t prec;
2468
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2469
2601
  MPFR *ptr_arg1, *ptr_return;
2470
2602
  VALUE val_ret;
2471
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2603
+ volatile VALUE tmp_argv0;
2604
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2605
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2472
2606
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2473
2607
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2474
2608
  r_mpfr_set_special_func_state(mpfr_j1(ptr_return, ptr_arg1, rnd));
@@ -2480,13 +2614,15 @@ static VALUE r_mpfr_math_jn(int argc, VALUE *argv, VALUE self)
2480
2614
  {
2481
2615
  mp_rnd_t rnd;
2482
2616
  mp_prec_t prec;
2483
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
2484
2617
  MPFR *ptr_arg1, *ptr_return;
2485
2618
  VALUE val_ret;
2486
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2619
+ volatile VALUE tmp_argv0;
2620
+ int n;
2621
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
2622
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2487
2623
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2488
2624
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2489
- int n = NUM2INT(argv[1]);
2625
+ n = NUM2INT(argv[1]);
2490
2626
  r_mpfr_set_special_func_state(mpfr_jn(ptr_return, n, ptr_arg1, rnd));
2491
2627
  return val_ret;
2492
2628
  }
@@ -2496,10 +2632,11 @@ static VALUE r_mpfr_math_y0(int argc, VALUE *argv, VALUE self)
2496
2632
  {
2497
2633
  mp_rnd_t rnd;
2498
2634
  mp_prec_t prec;
2499
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2500
2635
  MPFR *ptr_arg1, *ptr_return;
2501
2636
  VALUE val_ret;
2502
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2637
+ volatile VALUE tmp_argv0;
2638
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2639
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2503
2640
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2504
2641
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2505
2642
  r_mpfr_set_special_func_state(mpfr_y0(ptr_return, ptr_arg1, rnd));
@@ -2511,10 +2648,11 @@ static VALUE r_mpfr_math_y1(int argc, VALUE *argv, VALUE self)
2511
2648
  {
2512
2649
  mp_rnd_t rnd;
2513
2650
  mp_prec_t prec;
2514
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2515
2651
  MPFR *ptr_arg1, *ptr_return;
2516
2652
  VALUE val_ret;
2517
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2653
+ volatile VALUE tmp_argv0;
2654
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2655
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2518
2656
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2519
2657
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2520
2658
  r_mpfr_set_special_func_state(mpfr_y1(ptr_return, ptr_arg1, rnd));
@@ -2526,13 +2664,15 @@ static VALUE r_mpfr_math_yn(int argc, VALUE *argv, VALUE self)
2526
2664
  {
2527
2665
  mp_rnd_t rnd;
2528
2666
  mp_prec_t prec;
2529
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
2530
2667
  MPFR *ptr_arg1, *ptr_return;
2531
2668
  VALUE val_ret;
2532
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2669
+ volatile VALUE tmp_argv0;
2670
+ int n;
2671
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
2672
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2533
2673
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2534
2674
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2535
- int n = NUM2INT(argv[1]);
2675
+ n = NUM2INT(argv[1]);
2536
2676
  r_mpfr_set_special_func_state(mpfr_yn(ptr_return, n, ptr_arg1, rnd));
2537
2677
  return val_ret;
2538
2678
  }
@@ -2542,14 +2682,15 @@ static VALUE r_mpfr_math_fma(int argc, VALUE *argv, VALUE self)
2542
2682
  {
2543
2683
  mp_rnd_t rnd;
2544
2684
  mp_prec_t prec;
2545
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 3, 5, argc, argv);
2546
2685
  MPFR *ptr_arg1, *ptr_arg2, *ptr_arg3, *ptr_return;
2547
2686
  VALUE val_ret;
2548
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2687
+ volatile VALUE tmp_argv0, tmp_argv1, tmp_argv2;
2688
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 3, 5, argc, argv);
2689
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2549
2690
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2550
- volatile VALUE tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
2691
+ tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
2551
2692
  r_mpfr_get_struct(ptr_arg2, tmp_argv1);
2552
- volatile VALUE tmp_argv2 = r_mpfr_new_fr_obj(argv[2]);
2693
+ tmp_argv2 = r_mpfr_new_fr_obj(argv[2]);
2553
2694
  r_mpfr_get_struct(ptr_arg3, tmp_argv2);
2554
2695
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2555
2696
  r_mpfr_set_special_func_state(mpfr_fma(ptr_return, ptr_arg1, ptr_arg2, ptr_arg3, rnd));
@@ -2561,14 +2702,15 @@ static VALUE r_mpfr_math_fms(int argc, VALUE *argv, VALUE self)
2561
2702
  {
2562
2703
  mp_rnd_t rnd;
2563
2704
  mp_prec_t prec;
2564
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 3, 5, argc, argv);
2565
2705
  MPFR *ptr_arg1, *ptr_arg2, *ptr_arg3, *ptr_return;
2566
2706
  VALUE val_ret;
2567
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2707
+ volatile VALUE tmp_argv0, tmp_argv1, tmp_argv2;
2708
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 3, 5, argc, argv);
2709
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2568
2710
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2569
- volatile VALUE tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
2711
+ tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
2570
2712
  r_mpfr_get_struct(ptr_arg2, tmp_argv1);
2571
- volatile VALUE tmp_argv2 = r_mpfr_new_fr_obj(argv[2]);
2713
+ tmp_argv2 = r_mpfr_new_fr_obj(argv[2]);
2572
2714
  r_mpfr_get_struct(ptr_arg3, tmp_argv2);
2573
2715
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2574
2716
  r_mpfr_set_special_func_state(mpfr_fms(ptr_return, ptr_arg1, ptr_arg2, ptr_arg3, rnd));
@@ -2580,12 +2722,13 @@ static VALUE r_mpfr_math_agm(int argc, VALUE *argv, VALUE self)
2580
2722
  {
2581
2723
  mp_rnd_t rnd;
2582
2724
  mp_prec_t prec;
2583
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
2584
2725
  MPFR *ptr_arg1, *ptr_arg2, *ptr_return;
2585
2726
  VALUE val_ret;
2586
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2727
+ volatile VALUE tmp_argv0, tmp_argv1;
2728
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
2729
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2587
2730
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2588
- volatile VALUE tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
2731
+ tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
2589
2732
  r_mpfr_get_struct(ptr_arg2, tmp_argv1);
2590
2733
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2591
2734
  r_mpfr_set_special_func_state(mpfr_agm(ptr_return, ptr_arg1, ptr_arg2, rnd));
@@ -2597,12 +2740,13 @@ static VALUE r_mpfr_math_hypot(int argc, VALUE *argv, VALUE self)
2597
2740
  {
2598
2741
  mp_rnd_t rnd;
2599
2742
  mp_prec_t prec;
2600
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
2601
2743
  MPFR *ptr_arg1, *ptr_arg2, *ptr_return;
2602
2744
  VALUE val_ret;
2603
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2745
+ volatile VALUE tmp_argv0, tmp_argv1;
2746
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
2747
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2604
2748
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2605
- volatile VALUE tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
2749
+ tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
2606
2750
  r_mpfr_get_struct(ptr_arg2, tmp_argv1);
2607
2751
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2608
2752
  r_mpfr_set_special_func_state(mpfr_hypot(ptr_return, ptr_arg1, ptr_arg2, rnd));
@@ -2614,10 +2758,11 @@ static VALUE r_mpfr_math_ai(int argc, VALUE *argv, VALUE self)
2614
2758
  {
2615
2759
  mp_rnd_t rnd;
2616
2760
  mp_prec_t prec;
2617
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2618
2761
  MPFR *ptr_arg1, *ptr_return;
2619
2762
  VALUE val_ret;
2620
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2763
+ volatile VALUE tmp_argv0;
2764
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 1, 3, argc, argv);
2765
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2621
2766
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2622
2767
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2623
2768
  r_mpfr_set_special_func_state(mpfr_ai(ptr_return, ptr_arg1, rnd));
@@ -2629,9 +2774,9 @@ static VALUE r_mpfr_math_const_log2(int argc, VALUE *argv, VALUE self)
2629
2774
  {
2630
2775
  mp_rnd_t rnd;
2631
2776
  mp_prec_t prec;
2632
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
2633
2777
  MPFR *ptr_return;
2634
2778
  VALUE val_ret;
2779
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
2635
2780
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2636
2781
  r_mpfr_set_special_func_state(mpfr_const_log2(ptr_return, rnd));
2637
2782
  return val_ret;
@@ -2642,9 +2787,9 @@ static VALUE r_mpfr_math_const_pi(int argc, VALUE *argv, VALUE self)
2642
2787
  {
2643
2788
  mp_rnd_t rnd;
2644
2789
  mp_prec_t prec;
2645
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
2646
2790
  MPFR *ptr_return;
2647
2791
  VALUE val_ret;
2792
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
2648
2793
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2649
2794
  r_mpfr_set_special_func_state(mpfr_const_pi(ptr_return, rnd));
2650
2795
  return val_ret;
@@ -2655,9 +2800,9 @@ static VALUE r_mpfr_math_const_euler(int argc, VALUE *argv, VALUE self)
2655
2800
  {
2656
2801
  mp_rnd_t rnd;
2657
2802
  mp_prec_t prec;
2658
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
2659
2803
  MPFR *ptr_return;
2660
2804
  VALUE val_ret;
2805
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
2661
2806
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2662
2807
  r_mpfr_set_special_func_state(mpfr_const_euler(ptr_return, rnd));
2663
2808
  return val_ret;
@@ -2668,9 +2813,9 @@ static VALUE r_mpfr_math_const_catalan(int argc, VALUE *argv, VALUE self)
2668
2813
  {
2669
2814
  mp_rnd_t rnd;
2670
2815
  mp_prec_t prec;
2671
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
2672
2816
  MPFR *ptr_return;
2673
2817
  VALUE val_ret;
2818
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 0, 2, argc, argv);
2674
2819
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2675
2820
  r_mpfr_set_special_func_state(mpfr_const_catalan(ptr_return, rnd));
2676
2821
  return val_ret;
@@ -2685,17 +2830,15 @@ static VALUE r_mpfr_math_free_cache(VALUE self)
2685
2830
 
2686
2831
  /* Calculate sum of MPFR objects. */
2687
2832
  static VALUE r_mpfr_math_sum(int argc, VALUE *argv, VALUE self){
2688
- int num;
2833
+ int num, i;
2834
+ mp_rnd_t rnd;
2835
+ mp_prec_t prec;
2836
+ VALUE val_ret;
2689
2837
  for (num = 0; num < argc; num += 1) {
2690
2838
  if(!MPFR_P(argv[num])){ break; }
2691
2839
  }
2692
-
2693
- mp_rnd_t rnd;
2694
- mp_prec_t prec;
2695
2840
  r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, num, num + 2, argc, argv);
2696
2841
  MPFR *ptr_return, *ptr_args[num];
2697
- VALUE val_ret;
2698
- int i;
2699
2842
  for(i = 0; i < num; i++){
2700
2843
  volatile VALUE tmp_argvi = r_mpfr_new_fr_obj(argv[i]);
2701
2844
  r_mpfr_get_struct(ptr_args[i], tmp_argvi);
@@ -2714,12 +2857,13 @@ static VALUE r_mpfr_math_min(int argc, VALUE *argv, VALUE self)
2714
2857
  {
2715
2858
  mp_rnd_t rnd;
2716
2859
  mp_prec_t prec;
2717
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
2718
2860
  MPFR *ptr_arg1, *ptr_arg2, *ptr_return;
2719
2861
  VALUE val_ret;
2720
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2862
+ volatile VALUE tmp_argv0, tmp_argv1;
2863
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
2864
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2721
2865
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2722
- volatile VALUE tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
2866
+ tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
2723
2867
  r_mpfr_get_struct(ptr_arg2, tmp_argv1);
2724
2868
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2725
2869
  mpfr_min(ptr_return, ptr_arg1, ptr_arg2, rnd);
@@ -2731,12 +2875,13 @@ static VALUE r_mpfr_math_max(int argc, VALUE *argv, VALUE self)
2731
2875
  {
2732
2876
  mp_rnd_t rnd;
2733
2877
  mp_prec_t prec;
2734
- r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
2735
2878
  MPFR *ptr_arg1, *ptr_arg2, *ptr_return;
2736
2879
  VALUE val_ret;
2737
- volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2880
+ volatile VALUE tmp_argv0, tmp_argv1;
2881
+ r_mpfr_get_rnd_prec_from_optional_arguments(&rnd, &prec, 2, 4, argc, argv);
2882
+ tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
2738
2883
  r_mpfr_get_struct(ptr_arg1, tmp_argv0);
2739
- volatile VALUE tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
2884
+ tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
2740
2885
  r_mpfr_get_struct(ptr_arg2, tmp_argv1);
2741
2886
  r_mpfr_make_struct_init2(val_ret, ptr_return, prec);
2742
2887
  mpfr_max(ptr_return, ptr_arg1, ptr_arg2, rnd);
@@ -2804,9 +2949,11 @@ char *r_mpfr_dump_to_string(MPFR *ptr_s)
2804
2949
  static VALUE r_mpfr_marshal_dump(VALUE self)
2805
2950
  {
2806
2951
  MPFR *ptr_s;
2952
+ char *ret_str;
2953
+ VALUE ret_val;
2807
2954
  r_mpfr_get_struct(ptr_s, self);
2808
- char *ret_str = r_mpfr_dump_to_string(ptr_s);
2809
- VALUE ret_val = rb_str_new2(ret_str);
2955
+ ret_str = r_mpfr_dump_to_string(ptr_s);
2956
+ ret_val = rb_str_new2(ret_str);
2810
2957
  mpfr_free_str(ret_str);
2811
2958
  return ret_val;
2812
2959
  }
@@ -2820,9 +2967,9 @@ void r_mpfr_load_string(MPFR *ptr_s, const char *dump)
2820
2967
  if (type == MPFR_DUMP_NUMBER) {
2821
2968
  mpz_t m;
2822
2969
  long int e;
2970
+ int i;
2823
2971
  mpz_init(m);
2824
2972
  sscanf(dump, "%ld\t%ld\t", &prec, &e);
2825
- int i;
2826
2973
  i = 0;
2827
2974
  while (i < 2) {
2828
2975
  if (dump[0] == '\t') {
@@ -2980,6 +3127,8 @@ void Init_mpfr()
2980
3127
  r_mpfr_class = rb_define_class("MPFR", rb_cNumeric);
2981
3128
  rb_include_module(r_mpfr_class, rb_mComparable);
2982
3129
 
3130
+ __mpfr_domain_error__ = rb_define_class("MPFRDomainError", rb_eRangeError);
3131
+
2983
3132
  /* ------------------------------ Class MPFR End ------------------------------ */
2984
3133
 
2985
3134
  /* ------------------------------ Constants Start ------------------------------ */
@@ -3111,7 +3260,6 @@ void Init_mpfr()
3111
3260
 
3112
3261
  rb_define_method(r_mpfr_class, "get_d", r_mpfr_get_d, -1);
3113
3262
  rb_define_method(r_mpfr_class, "get_d_2exp", r_mpfr_get_d_2exp, -1);
3114
- rb_define_method(r_mpfr_class, "get_si", r_mpfr_get_si, -1);
3115
3263
  rb_define_method(r_mpfr_class, "get_str", r_mpfr_get_str, 0);
3116
3264
 
3117
3265
  rb_define_method(r_mpfr_class, "round", r_mpfr_round_to_i, 0);
@@ -3161,8 +3309,8 @@ void Init_mpfr()
3161
3309
  rb_define_alias(r_mpfr_class, "nan?", "nan_p");
3162
3310
  rb_define_alias(r_mpfr_class, "finite?", "number_p");
3163
3311
  rb_define_alias(r_mpfr_class, "zero?", "zero_p");
3164
- rb_define_method(r_mpfr_class, "nonzero?", r_mpfr_nonzero_p, 1);
3165
- rb_define_method(r_mpfr_class, "regular?", r_mpfr_regular_p, 1);
3312
+ rb_define_method(r_mpfr_class, "nonzero?", r_mpfr_nonzero_p, 0);
3313
+ rb_define_method(r_mpfr_class, "regular?", r_mpfr_regular_p, 0);
3166
3314
 
3167
3315
  /* ------------------------------ Comparison Functions Start ------------------------------ */
3168
3316