Jump to content
Neil

Float Lib Bug

Recommended Posts

Hi

 

It seems that code like:

 

float foo;

float bar[2];

 

foo = bar[1];

 

does not correctly copy values. You can work round this using

 

memcpy((void*)&foo, (void*)&bar[1], 4)

 

 

Neil

 

OS XPpro, BoostC++ 6.90 PIC18f8722

Edited by Neil

Share this post


Link to post
Share on other sites

Works for me Neil using the same set-up as you. Simulator shows 4 byte copied.

 

float foo;

float bar[2] = {1.23,4.56};

foo = bar[1];

 

Simulator gives foo = 4.5599999

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

Hi Reynard

 

It seems you are the only one who ever replys to me!!

 

I dod not use the simulator, I used a real PIC18. May be that accounts for the difference?

 

Neil

Share this post


Link to post
Share on other sites

Don't get too upset Neil, I talk to anyone ;)

 

	foo = bar[1];
005E  5005		  MOVF gbl_bar+D'4', W
0060  6E09		  MOVWF gbl_foo
0062  5006		  MOVF gbl_bar+D'5', W
0064  6E0A		  MOVWF gbl_foo+D'1'
0066  5007		  MOVF gbl_bar+D'6', W
0068  6E0B		  MOVWF gbl_foo+D'2'
006A  5008		  MOVF gbl_bar+D'7', W
006C  6E0C		  MOVWF gbl_foo+D'3'

 

The assembler code appear to copy the 4 bytes.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...