0

Swift documentation has let hexadecimalDouble = 0xC.3p0 which apparently equals 12.1875.. Maybe I'm not understanding something with the notation, but I'm not sure how 12.1875 is derived, specifically the '1875' part.

Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128
ajc
  • 13
  • 2
  • If you would like to write that in Swift it would look like `(12 * pow(Double(16),0) + 3/pow(Double(16),1)) * pow(Double(2),0)`. Note that anything powered zero equals 1 and anything powered to 1 remains the same. Therefore it can also be written as `12.0 + 3/16` – Leo Dabus May 29 '22 at 02:01
  • If you would like to expand on that `0xCE.FEAp2` equals `827.978515625` which can also be written in Swift as `(12.0 * pow(Double(16),1) + 14 * pow(Double(16),0) + 15/pow(Double(16),1) + 14/pow(Double(16),2) + 10/pow(Double(16),3)) * pow(Double(2),2)` or simply `(12.0 * 16 + 14 + 15/16 + 14/pow(Double(16),2) + 10/pow(Double(16),3)) * pow(Double(2),2)` – Leo Dabus May 29 '22 at 02:02

0 Answers0