CW11.1 for MCU watch float Format=Hexadecimal problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CW11.1 for MCU watch float Format=Hexadecimal problem

695 Views
kef2
Senior Contributor IV

Hi,

Incorrect values displayed when watching expressions or variables formatted as Hexadecimal. What I want to see is real memory representation of particular FP variables.

CW seems converting floating point to string with limited amount of digits past the decimal point, then converting string back to floating point, and only then displaying FP binary representation as Hexadecimal.

fmtpb3.png

fmtpb1.png

fmtpb2.png

As you may see in memory I have 0x01800000 and IDE fools me as if there was 0x017FFFFF. Both variables and expressions the same bug.

More digits of Z (0x01800000) are 4.70197740328915E-38.

0x017FFFFF is 4.70197712302946E-38

So please double convert forwards and backwards using at least one more decimal digit past the dot, better two, or even better don't double convert at all.

0 Kudos
5 Replies

596 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Edward Karpicz

What's your chip part number? please let us know thus we can assign the right support engineer to help you.

Jun Zhang

0 Kudos

596 Views
kef2
Senior Contributor IV

Hi,

sorry I didn't mention MCU, it's S912ZVCA19F0MLF. I thought it's common for all MCUs, perhaps not.

Thanks,

Edward

0 Kudos

596 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

This is IEEE floating point precision problem.

Could you please send me your demo project? I will check it directly.

Jun Zhang

0 Kudos

596 Views
kef2
Senior Contributor IV

Dear Jun,

please don't blame innocent IEEE floating point, even don't try!!! Please read my original post again. Problem is not the precision of the math, problem is that CodeWarrior debugger fools me lying about the memory contents. I want to look at how my number looks like in memory, what its hexadecimal representation in memory, and debugger shows some bits and even whole bytes wrong!

One more example, see attached:

Z = 1.0/3.0; // compile time constant, no calculations

In memory 3E AA AA AB, in variables view - 0x3eaaaa9f. Whole least significant byte wrong! Classic CW 5.1 wasn't fooling me like this, never!

It is very obvious that modern debugger reads float from memory, converts it in memory to string with *too few digits after the dot*, converts resulting string back to float, and then treats it as integer. Why not reading directly as long when I ask for Hexadecimal, with double conversion?

I could use Memory View, but it takes ages then to single step! Yes, that's yet another problem of modern CW. How to trim memory view to view just as many bytes as I want, so that it won't take ages to update?

Regards,

Edward

0 Kudos

596 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Thanks for the demo. I reproduce the issue.

I will escalate it to development team. I will let you know when I get feedback.

Jun Zhang

0 Kudos