Skip to content

[AVR] result of i32 as f32 is incorrect #77131

Closed
@jsen-

Description

@jsen-

I tried this code: https://github.com/jsen-/rust-i32-as-f32-issue-repro

I expected to see this happen:
Every i32 value converted to f32 should have equal decimal part and zeros-only after decimal point.

Instead, this happened:

i32   manual   using "as"
      conv.
----------------------------
0     0.0000   0.0000
1     1.0000   1.0078
2     2.0000   2.0313
3     3.0000   2.0469
4     4.0000   4.1250
5     5.0000   4.1563
6     6.0000   4.1875
7     7.0000   4.2188
8     8.0000   8.5000
9     9.0000   8.5625
10   10.0000   8.6250
11   11.0000   8.6875
12   12.0000   8.7500
13   13.0000   8.8125
14   14.0000   8.8750
15   15.0000   8.9375
16   16.0000  18.0000
...

full output

Meta

rustc --version --verbose:

rustc 1.48.0-nightly (0da580074 2020-09-22)
binary: rustc
commit-hash: 0da58007451a154da2480160429e1604a1f5f0ec
commit-date: 2020-09-22
host: x86_64-unknown-linux-gnu
release: 1.48.0-nightly
LLVM version: **11.0**

tested on arduino nano

Note: I updated compiler-builtins to 0.1.36, because without this commit I was getting undefined symbols __ashlsi3 and __lshrsi3

Note2:: Debug builds don't link due to missing references core::panicking::panic::hc30e67a739c4d8d1, but that's a separate issue. Release builds fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-floating-pointArea: Floating point numbers and arithmeticC-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleO-AVRTarget: AVR processors (ATtiny, ATmega, etc.)requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions