0

I have a question about exponents in for decimal float exponents.

Decimal

 let decimalTest = 2e3   

which is

2 * 10^3 = 2000

Hexadecimal

let hexaTest = 0x2p3   

which is

2 * 2^3 = 16  

Why would the hexadecimal be multiplied by an exponent with a base of 2 instead of 16?

edit: formatting & forgot to declare hexadecimal for the hexaTest

user3435505
  • 157
  • 2
  • 10
  • You might want to look at the following SO question since this question has been asked before and very thoroughly answered :) http://stackoverflow.com/questions/24477546/why-does-swift-use-base-2-for-the-exponent-of-hexadecimal-floating-point-values – Fahim Mar 22 '17 at 08:16
  • Thanks for the comment! – user3435505 Mar 22 '17 at 08:18

0 Answers0