int_fast16_t?

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is there any difference between int16_t and int_fast16_t data types?

In stdint.h I see that int_fast16_t is typedef'd to int16_t, which makes me think there's no difference. The compiler doesn't do any special optimization with 'fast' integer types, does it?

(Unfortunately I need to do a lot of 16-bit math in my code, so I'm trying to squeeze every bit of juice out of the AVR that I can.)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

autorelease wrote:
The compiler doesn't do any special optimization with 'fast' integer types, does it?

It doesn't.

Stefan Ernst

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The original intent behind the fast integer types was for use in various architectures which incur a serious performance penalty if they actually store integers in memory with fewer bits than one of their "native" integer sizes. Basically, the variable would be stored with at least as many bits as you specified, but possibly with more bits if it would result in better performance.

In an AVR, where the native register size is already 1 byte, you'd would be very unlikely to find an instance where the fast integer types are ever actually implemented any differently than the exact-size integer types.