Boost logo

Boost :

From: michael toksvig (michaeltoksvig_at_[hidden])
Date: 2005-09-17 01:34:13

a counter-question, rob: how would you handle the addition of 2 numbers
between 90 and 100, in your model?

there are no possible outputs (180-200) within the input range (90-100). if,
as i believe you suggest, the output range must match the input range, you
would have to cast the inputs to match the output range. but the input and
output ranges are disjunct

one solution would be to cast the inputs to the union of the output and
input ranges (90-200), then perform the addition. of course, you would then
want to cast the result back to the real output range of 180-200

that seems cumbersome to me, but more importantly, you lose the opportunity
for letting the compiler provide valuable validation of your design

in my field (digital electronics) at least, there is little use for
operators that are unable to produce results outside of the input range

examples of trivial operations that do not adhere to that limitation
- adding two 5 bit integers (result must be stored in a 6 bit integer)
- multiplying an 11 bit integer by a 16 bit integer (result must be stored
in a 27 bit integer)
- shifting an 11 bit integer up by 5 positions (result must be stored in a
16 bit integer)

granted, my field is somewhat specialized, but i don't think that the case
where the minimum and maximum voltage of both your batteries happens to
match the minimum and maximum voltage of your input is all that common. is
it really that practical to hook two 2V-5V batteries in serial up to a 2V-5V
input? more common than a 4V-10V input? or even a 2V-7V input? i mean: the
latter would at least allow you to fully charge one of the batteries without
destroying the system


/michael toksvig

Boost list run by bdawes at, gregod at, cpdaniel at, john at