Make lm35 convert function use i32 for uom base type for voltage and temperature #10

Closed
opened 2024-02-19 00:20:24 +00:00 by zack · 1 comment
Owner

Integer operations may be faster on some devices. All possible values and all arithmetic needed for the conversion can fit in and be done with an i32. The cast to a f32 should always be a single fast instruction. Should we:

  1. Switch the convert function to use i32.
  2. Add an i32 version of the convert function in addition to the f32 version.
  3. Make the uom base type generic for the convert function.
  4. Leave it as it is.
Integer operations may be faster on some devices. All possible values and all arithmetic needed for the conversion can fit in and be done with an `i32`. The cast to a `f32` should always be a single fast instruction. Should we: 1. Switch the convert function to use `i32`. 1. Add an `i32` version of the convert function in addition to the f32 version. 1. Make the uom base type generic for the convert function. 1. Leave it as it is.
zack added the
enhancement
proposed
implementation
needs assignee
labels 2024-02-19 00:20:24 +00:00
Author
Owner

It's problem is to scale we need to convert the voltage to a certain unit. To not use a decimal and get full accuracy that unit would need to be millivolts but if we use millivolts instead of volts we would need to divide instead of multiply and integer division would presumably be much slower than even float multiplication so we will leave it as f32.

It's problem is to scale we need to convert the voltage to a certain unit. To not use a decimal and get full accuracy that unit would need to be millivolts but if we use millivolts instead of volts we would need to divide instead of multiply and integer division would presumably be much slower than even float multiplication so we will leave it as f32.
zack closed this issue 2024-02-23 17:18:18 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: BFPOWER/physical#10
No description provided.