mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 07:33:01 +00:00 
			
		
		
		
	Fix bad integer printing range.
This commit is contained in:
		| @@ -37,7 +37,11 @@ | ||||
|  | ||||
| static void number_to_string_b(JanetBuffer *buffer, double x) { | ||||
|     janet_buffer_ensure(buffer, buffer->count + BUFSIZE, 2); | ||||
|     const char *fmt = (x == floor(x) && x <= 2.0e53 && x >= -2.0e53) ? "%.0f" : "%g"; | ||||
|     /* Use int32_t range for valid integers because that is the | ||||
|      * range most integer-expecting functions in the C api use. */ | ||||
|     const char *fmt = (x == floor(x) && | ||||
|                        x <= ((double) INT32_MAX) && | ||||
|                        x >= ((double) INT32_MIN)) ? "%.0f" : "%g"; | ||||
|     int count = snprintf((char *) buffer->data + buffer->count, BUFSIZE, fmt, x); | ||||
|     buffer->count += count; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose