Ultra-wideband (UWB) and WiFi technologies have been widely proposed for the implementation of accurate and scalable indoor positioning systems (IPSs). Among different approaches, fingerprinting appears particularly suitable for WiFi IPSs and was also proposed for UWB IPSs, in order to cope with the decrease in accuracy of time of arrival (ToA)-based lateration schemes in the case of severe multipath and non-line-of-sight (NLoS) environments. However, so far, the two technologies have been analyzed under very different assumptions, and no fair performance comparison has been carried out. This paper fills this gap by comparing UWB-and WiFi-based fingerprinting under similar settings and scenarios by computer simulations. Two different k-nearest neighbor (kNN) algorithms are considered in the comparison: a traditional fixed k algorithm, and a novel dynamic k algorithm capable of operating on fingerprints composed of multiple location-dependent features extracted from the channel impulse response (CIR), typically made available by UWB hardware. The results show that UWB and WiFi technologies lead to a similar accuracy when a traditional algorithm using a single feature is adopted; when used in combination with the proposed dynamic k algorithm operating on channel energy and delay spread, UWB outperforms WiFi, providing higher accuracy and more degrees of freedom in the design of the system architecture.