arduino / arduino/ArduinoCore-API
map() for float data type
- 主要语言
- C++
- 星标
- 306
- 派生
- 150
- PR 合并指标
- 30 天内没有已合并 PR
描述
If a `float` argument is passed to the `map()` function, it truncates them to integer values. This provides erroneous output that may not be immediately noticed. This does not produce a compiler warning.
Please add a `float` variant of `map()`:
```cpp
float mapf(float value, float istart, float istop, float ostart, float ostop) {
return ostart + (ostop - ostart) * ((value - istart) / (istop - istart));
}
```
### Additional context
#### Additional reports
- https://dicks-photon-arduino.blogspot.com/2016/05/40-arduino-c-map-function-vs.html
#### Related
- https://github.com/arduino/Arduino/issues/288
贡献指南
这个仓库没有索引到贡献指南
调研方向
首先在 ArduinoCore-API 中找到现有的 map() 入口点,并检查它如何处理数值输入和输出。当针对 float 的映射 API 能够保留 float 参数的小数值,同时保持现有 map() 行为不变时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- cpp
- 领域
- api
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100