mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	parse.y: calculate powers of ten
* parse.y (parser_yylex): calculate denominator directly as powers of ten, not parsing string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									0eab2b464e
								
							
						
					
					
						commit
						7c9a3d19fc
					
				
					 4 changed files with 14 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -1,4 +1,7 @@
 | 
			
		|||
Fri Aug  2 23:14:54 2013  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
Fri Aug  2 23:48:36 2013  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* parse.y (parser_yylex): calculate denominator directly as powers of
 | 
			
		||||
	  ten, not parsing string.
 | 
			
		||||
 | 
			
		||||
	* parse.y (parser_number_literal_suffix): return bit set of found
 | 
			
		||||
	  suffixes.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -503,6 +503,9 @@ VALUE rb_big_sq_fast(VALUE x);
 | 
			
		|||
/* io.c */
 | 
			
		||||
void rb_maygvl_fd_fix_cloexec(int fd);
 | 
			
		||||
 | 
			
		||||
/* numeric.c */
 | 
			
		||||
VALUE rb_int_positive_pow(long x, unsigned long y);
 | 
			
		||||
 | 
			
		||||
/* process.c */
 | 
			
		||||
int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen);
 | 
			
		||||
rb_pid_t rb_fork_async_signal_safe(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds, char *errmsg, size_t errmsg_buflen);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2986,6 +2986,12 @@ int_pow(long x, unsigned long y)
 | 
			
		|||
    return LONG2NUM(z);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
VALUE
 | 
			
		||||
rb_int_positive_pow(long x, unsigned long y)
 | 
			
		||||
{
 | 
			
		||||
    return int_pow(x, y);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 *  call-seq:
 | 
			
		||||
 *    fix ** numeric  ->  numeric_result
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								parse.y
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								parse.y
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -7649,9 +7649,7 @@ parser_yylex(struct parser_params *parser)
 | 
			
		|||
		    type = tRATIONAL;
 | 
			
		||||
		    memmove(point, point+1, fraclen+1);
 | 
			
		||||
		    v = rb_cstr_to_inum(tok(), 10, FALSE);
 | 
			
		||||
		    *point = '1';
 | 
			
		||||
		    memset(point+1, '0', fraclen);
 | 
			
		||||
		    v = rb_rational_new(v, rb_cstr_to_inum(point, 10, FALSE));
 | 
			
		||||
		    v = rb_rational_new(v, rb_int_positive_pow(10, fraclen));
 | 
			
		||||
		}
 | 
			
		||||
		else {
 | 
			
		||||
		    double d = strtod(tok(), 0);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue