不幸的是,在不需要经过汇编的外部依赖的情况下,没有类似的条件。 根据你们的需要,我做了以下工作:。 可能提供帮助。
它暴露了以下功能:opFrac(num)
,即选择性地将某一吨、浮标或Fraction转换为具有排位限制的浮标或Fraction(因为我使用65535号,因为Im与小分数做生意);如果该浮标能够确切地在双位(即它拥有两个排位数的多种力量),则只剩下。 否则,它就将它变为“框架”。 同样,如果《框架》在双程中确实具有代表性,那么我们就把它变成了浮标;否则,我们就离开了。
The actionFr(float).limit_denominator(x)
calls is derived out into a helper function, _preFracLimitDenominator
, that only establishs one Fr>
Object, but not the three average established with the calls.
The use cases for this gist are pretty few, but where they exist, the results are spectacular. For my project, music21, we work mostly with notes that are generally placed on a beat (integer) or on a half, quarter, eighth, etc. beat (exactly representable in binary), but on the rarer occasions when notes have placement (offset) or duration that is, say, 1/3 or 1/5 of a beat, we were running into big floating point conversion problems that led to obscure bugs. Our test suite was running in 350 seconds using floating point offsets and durations. Switching everything to Fractions ballooned the time to 1100 seconds -- totally unacceptable. Switching to optional Fractions with fast Fraction creation brought the time back to 360 seconds, or only a 3% performance hit.
如果你有时能够处理浮标问题,有时甚至处理不成体系问题,那可能是前进的道路。