mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	video_core: fix infinity and NaN conversions
This commit is contained in:
		
							parent
							
								
									4b8a7eb1ca
								
							
						
					
					
						commit
						fd3ec6be30
					
				
					 1 changed files with 11 additions and 5 deletions
				
			
		|  | @ -35,13 +35,19 @@ public: | |||
| 
 | ||||
|         const int width = M + E + 1; | ||||
|         const int bias = 128 - (1 << (E - 1)); | ||||
|         const int exponent = (hex >> M) & ((1 << E) - 1); | ||||
|         int exponent = (hex >> M) & ((1 << E) - 1); | ||||
|         const unsigned mantissa = hex & ((1 << M) - 1); | ||||
|         const unsigned sign = (hex >> (E + M)) << 31; | ||||
| 
 | ||||
|         if (hex & ((1 << (width - 1)) - 1)) | ||||
|             hex = ((hex >> (E + M)) << 31) | (mantissa << (23 - M)) | ((exponent + bias) << 23); | ||||
|         else | ||||
|             hex = ((hex >> (E + M)) << 31); | ||||
|         if (hex & ((1 << (width - 1)) - 1)) { | ||||
|             if (exponent == (1 << E) - 1) | ||||
|                 exponent = 255; | ||||
|             else | ||||
|                 exponent += bias; | ||||
|             hex = sign | (mantissa << (23 - M)) | (exponent << 23); | ||||
|         } else { | ||||
|             hex = sign; | ||||
|         } | ||||
| 
 | ||||
|         std::memcpy(&res.value, &hex, sizeof(float)); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue