basvandijk / scientific

Arbitrary-precision floating-point numbers represented using scientific notation
BSD 3-Clause "New" or "Revised" License
73 stars 40 forks source link

Add ability to configure normalization #32

Closed centromere closed 7 years ago

centromere commented 9 years ago

I recently ran in to an issue where I needed to print out non-normalized Scientific values. The pretty-printing functions normalize by default, and there's no way to configure it. It would be super helpful if formatScientificBuilder took an extra Bool argument specifying the normalization preference.

basvandijk commented 9 years ago

Could you explain a bit more about your use case?

I don't like breaking the API so in order to do this I need to add the following new functions:

I need to have a good reason to justify this API increase.

centromere commented 9 years ago

I'm accepting HTTP requests, converting them to JSON-RPC requests, and sending them off to RabbitMQ. The HTTP requests include authentication headers (HMAC signature and timestamp to prevent replay attacks). The timestamp can be fractional, and is represented as a Scientific. The problem is that since the timestamp is signed, it has to be represented exactly as the client sent it in the HTTP headers. Normalization can prevent the signatures from being verified properly.

basvandijk commented 7 years ago

I think I would accept a PR for this.

centromere commented 7 years ago

Must it be strictly non-breaking?