Unless there is a very strong argument and the situation is unavoidable I would recommend that you avoid this conversion in the contract.
It is perfectly reasonable to insist that client-side software accommodate the contract and not the other way around. A partial list of reasons:
- Contracts are (generally) immutable. This raises the importance of QA. A first line of defense is maximum simplicity. The conversion function may indeed be okay (or not) but it certainly is a lot for reviewers/auditors/attackers to think about.
- Gas cost. All those ops will be replicated by all full nodes and a significant cost to everyone who uses the contract. The conversion function is well-suited to off-chain preprocessing in clients/servers where processing capacity is plentiful and nearly free.
I can think of a case where the inputs come from two different contracts and you want the comparison to happen on-chain.
If it is possible to avoid this, then you should avoid it.
Hope it helps.