View Single Post
Old 03-01-2017, 01:38 AM   #86 (permalink)
t vago
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Hungary
Posts: 1,807

iNXS - '10 Opel Zafira 111 Anniversary

Suzi - '02 Suzuki Swift GL
Thanks: 828
Thanked 708 Times in 456 Posts
Quote:
Originally Posted by skybolt View Post
Well, then now is a good time as any to roll out this potato: I need your routine to calculate mileage down to the ten-thousandth, which will result in resolution of about a foot. (In my car, technically, 6.7 inches, which is actually good to display to the foot; based, sort of, on the 2x sampling principle).
I've been tossing around this potato in my head for the past week. I think I may have come up with a solution - it's based on how my code currently handles metric vs. SAE measurements. Been kind of busy lately, though, so can't give you a definitive date as to when it will be available.

Along with coding this, going to also strip out the validation checks on the VSS signal. I really can't see any point to having them there. Debouncing should work just fine for slower mechanical VSS generators, and more recent solid-state generators don't need debounce anyhow.

Quote:
Originally Posted by skybolt View Post
That said, a quick question: Are conditional if/then statements computationally efficient?
Inasmuch as a conditional does not actually calculate anything, then no, they're not computationally efficient. However, conditionals are indispensable to computing, so there is that to consider.

There are different structures that conditionals may take, which tend to minimize the required overhead. Jump tables tend to be the most efficient, because the conditional has been boiled down to an index that can be used to pull an address from said jump table. Jump tables tend to be the most flexible, too, because you can assign a certain action to be performed if the conditional variable reaches a certain value, and then perform another related action that would normally be called for if the conditional variable reached some other value. Jump tables are generated by C++'s switch/case/default statement blocks.
  Reply With Quote