mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-31 14:02:59 +00:00 
			
		
		
		
	conversion from ld to bignum
This commit is contained in:
		
							
								
								
									
										10
									
								
								util.cpp
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								util.cpp
									
									
									
									
									
								
							| @@ -300,6 +300,7 @@ struct bignum { | |||||||
|   bignum& operator +=(const bignum& b); |   bignum& operator +=(const bignum& b); | ||||||
|   void addmul(const bignum& b, int factor); |   void addmul(const bignum& b, int factor); | ||||||
|   string get_str(int max_length) const; |   string get_str(int max_length) const; | ||||||
|  |   bignum(ld d); | ||||||
|    |    | ||||||
|   bool operator < (const bignum&) const; |   bool operator < (const bignum&) const; | ||||||
|  |  | ||||||
| @@ -472,4 +473,13 @@ string bignum::get_str(int max_length) const { | |||||||
|   return ret; |   return ret; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | bignum::bignum(ld d) { | ||||||
|  |   if(d == 0) return; | ||||||
|  |   int n = 1; | ||||||
|  |   while(d > BASE) d /= BASE, n++; | ||||||
|  |   digits.resize(n); | ||||||
|  |   n--; | ||||||
|  |   while(n >= 0) { digits[n] = int(d); d -= digits[n]; d *= BASE; n--; } | ||||||
|  |   } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue