Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
Laks
PostPosted: Jun 07, 2007 - 07:53 PM
Newbie


Joined: Dec 29, 2003
Posts: 14


Hello All!

What is "float" in WinAVR?

The user IAR can open a file of the help:
"...\IAR Systems\Embedded Workbench 4.0 Evaluation\avr\doc\EWAVR_CompilerReference.pdf"
and to find there table with the description float and double.
___________________________________
FLOATING-POINT TYPES
In the AVR IAR C/C++ Compiler, floating-point values are represented in standard
IEEE format.
The ranges and sizes for the different floating-point types are:

Type__________ Size____ Range (+/-)__________________ Exponent_ Mantissa
float__________ 32 bits ▒1.18E-38 to ▒3.39E+38___________ 8 bits 23 bits
double_______ * 32 bits (default) ▒1.18E-38 to ▒3.39E+38_ 8 bits 23 bits
double_______ * 64 bits ▒2.23E-308 to ▒1.79E+308________ 11 bits 52 bits
long double__ * 32 bits ▒1.18E-38 to ▒3.39E+38___________ 8 bits 23 bits
long double__ * 64 bits ▒2.23E-308 to ▒1.79E+308________ 11 bits 52 bits
Table 32: Floating-point types
___________________________________
and there is a lot of other information on float and double.

Whether there is somewhere similar information for WinAVR?
I could not find anything neither in a folder "WinAVR", nor in the Internet.
Whether somebody can show me how find such information?

I have found some good pages
http://en.wikipedia.org/wiki/IEEE_floating-point
http://c0x.coding-guidelines.com/5.2.4.2.2.html
But it is not clear for me as them to coordinate with WinAVR.
 
 View user's profile Send private message  
Reply with quote Back to top
dl8dtl
PostPosted: Jun 07, 2007 - 08:46 PM
Raving lunatic


Joined: Dec 20, 2002
Posts: 7374
Location: Dresden, Germany

AVR-GCC (currently) implements both, float and double as 32-bit IEEE 754
floating-point numbers, so the above figures for 32-bit numbers apply.
(long double is essentially the same as well.)

_________________
J├Ârg Wunsch

Please don't send me PMs, use email if you want to approach me personally.
Please read the `General information...' article before.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Laks
PostPosted: Jun 07, 2007 - 10:28 PM
Newbie


Joined: Dec 29, 2003
Posts: 14


Thank to you for the answer. And whence you know it? Can give the link to this information?
 
 View user's profile Send private message  
Reply with quote Back to top
dl8dtl
PostPosted: Jun 07, 2007 - 11:11 PM
Raving lunatic


Joined: Dec 20, 2002
Posts: 7374
Location: Dresden, Germany

> And whence you know it?

Well, I'm an avr-libc maintainer, so I better ought to know what the
compiler does, don't you think so? ;-)

_________________
J├Ârg Wunsch

Please don't send me PMs, use email if you want to approach me personally.
Please read the `General information...' article before.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Laks
PostPosted: Jun 07, 2007 - 11:38 PM
Newbie


Joined: Dec 29, 2003
Posts: 14


Oh, it is good, if somebody will set to me this question, I shall refer him to this page as on a manual Smile.
 
 View user's profile Send private message  
Reply with quote Back to top
dl8dtl
PostPosted: Jun 07, 2007 - 11:41 PM
Raving lunatic


Joined: Dec 20, 2002
Posts: 7374
Location: Dresden, Germany

You could as well refer him to <limits.h>.

_________________
J├Ârg Wunsch

Please don't send me PMs, use email if you want to approach me personally.
Please read the `General information...' article before.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Laks
PostPosted: Jun 08, 2007 - 12:34 AM
Newbie


Joined: Dec 29, 2003
Posts: 14


But in <limits.h> no mention "float", only integer.

And integer, IMHO, are well explained in <stdint.h> and
:/WinAVR-20070525/doc/avr-libc/avr-libc-user-manual/group__avr__stdint.html
define INT8_MAX 0x7f
...
define INT8_MIN (-INT8_MAX - 1)
...
define UINT8_MAX (__ CONCAT (INT8_MAX, U) * 2U + 1U)
etc.
I understand it.
_____________________________________

But in <limits.h>
#define CHAR_BIT __CHAR_BIT__
...
#define SCHAR_MIN (-SCHAR_MAX - 1)
CHAR_BIT, SCHAR_MIN, etc. It is not clear for me where they are defined.
I do not know what to do with this. But I still far from such details.
 
 View user's profile Send private message  
Reply with quote Back to top
dl8dtl
PostPosted: Jun 08, 2007 - 10:10 AM
Raving lunatic


Joined: Dec 20, 2002
Posts: 7374
Location: Dresden, Germany

Yeah, sorry, I meant <float.h> (it's been a bit late already last night).
However, it's right, you have to run that through the preprocessor in
order to get some real information out of it:

Code:

$ # create empty file foo.c
$ touch foo.c
$ # run it through the preprocessor, list all macros
$ # with their values, pick the FP-related ones, and
$ # sort them alphabetically
$ avr-gcc -E -dM foo.c | grep -E 'FLT|DBL' | sort
#define __DBL_DENORM_MIN__ 1.40129846e-45
#define __DBL_DIG__ 6
#define __DBL_EPSILON__ 1.19209290e-7
#define __DBL_HAS_INFINITY__ 1
#define __DBL_HAS_QUIET_NAN__ 1
#define __DBL_MANT_DIG__ 24
#define __DBL_MAX_10_EXP__ 38
#define __DBL_MAX_EXP__ 128
#define __DBL_MAX__ 3.40282347e+38
#define __DBL_MIN_10_EXP__ (-37)
#define __DBL_MIN_EXP__ (-125)
#define __DBL_MIN__ 1.17549435e-38
#define __FLT_DENORM_MIN__ 1.40129846e-45F
#define __FLT_DIG__ 6
#define __FLT_EPSILON__ 1.19209290e-7F
#define __FLT_EVAL_METHOD__ 0
#define __FLT_HAS_INFINITY__ 1
#define __FLT_HAS_QUIET_NAN__ 1
#define __FLT_MANT_DIG__ 24
#define __FLT_MAX_10_EXP__ 38
#define __FLT_MAX_EXP__ 128
#define __FLT_MAX__ 3.40282347e+38F
#define __FLT_MIN_10_EXP__ (-37)
#define __FLT_MIN_EXP__ (-125)
#define __FLT_MIN__ 1.17549435e-38F
#define __FLT_RADIX__ 2
#define __LDBL_DENORM_MIN__ 1.40129846e-45L
#define __LDBL_DIG__ 6
#define __LDBL_EPSILON__ 1.19209290e-7L
#define __LDBL_HAS_INFINITY__ 1
#define __LDBL_HAS_QUIET_NAN__ 1
#define __LDBL_MANT_DIG__ 24
#define __LDBL_MAX_10_EXP__ 38
#define __LDBL_MAX_EXP__ 128
#define __LDBL_MAX__ 3.40282347e+38L
#define __LDBL_MIN_10_EXP__ (-37)
#define __LDBL_MIN_EXP__ (-125)
#define __LDBL_MIN__ 1.17549435e-38L

_________________
J├Ârg Wunsch

Please don't send me PMs, use email if you want to approach me personally.
Please read the `General information...' article before.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
clawson
PostPosted: Jun 08, 2007 - 11:10 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 71149
Location: (using avr-gcc in) Finchingfield, Essex, England

Laks wrote:
Can give the link to this information?

There's a passing reference to the float=double=32bits thing in the user manual:

http://www.nongnu.org/avr-libc/user-man ... _reg_usage
Quote:
float and double are 32 bits (this is the only supported floating point format),

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
Laks
PostPosted: Jun 08, 2007 - 12:07 PM
Newbie


Joined: Dec 29, 2003
Posts: 14


Thank you very much for answers and for WinAVR!
 
 View user's profile Send private message  
Reply with quote Back to top
HJHerbert
PostPosted: Jun 10, 2007 - 10:13 PM
Newbie


Joined: Feb 11, 2007
Posts: 17


Link :

http://www.avrfreaks.net/wiki/index.php ... :AVR_Float

_________________
Weiterstadt, Germany
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits