Getting a float division from integers

AWOL: For a float constant or variable, the compiler reserves at most, four bytes.

I'm taking about flash memory space, not used ram.

casemod:

AWOL: For a float constant or variable, the compiler reserves at most, four bytes.

I'm taking about flash memory space, not used ram.

My concern is why the compiler reserves so much space for a float.

The compiler reserves four bytes for a float. Why you consider four bytes "so much space" I really can't tell.

casemod:

AWOL:

My sketch was 2.5K, enabling a single float makes it 4.2K, everything else being equal.

And does "enabling" two floats make the sketch 5.9K? I think not.

Most certainly not, I do get an increase of about 150bytes. That should be good for the float, so the missing 1.7K are still somewhere. Doing god knows what. ....

When one or more floats are used, the compiler links in a float math library which costs additional memory, more than just the four bytes for a float.

AWOL:

casemod:

AWOL: For a float constant or variable, the compiler reserves at most, four bytes.

I'm taking about flash memory space, not used ram.

My concern is why the compiler reserves so much space for a float.

The compiler reserves four bytes for a float. Why you consider four bytes "so much space" I really can't tell.

Ok, so perhaps i didn't clarify the issue correctly on the first place. The float does indeed use 4 bytes of dynamic memory as you mention. not an issue.

What I don't understand is why the code size gets so large by declaring a float. When working with smaller processors, such as the ATTiny this quickly becomes an issue.

The float does indeed use 4 bytes of dynamic memory as you mention. not an issue.

No, theer is exactly zero dynamic memory in the Arduino. a float uses no dynamic memory.

Read reply #22 again.

The float does indeed use 4 bytes of dynamic memory

RAM on the AVR is static, not dynamic.

What I don't understand is why the code size gets so large by declaring a float

Because the AVR doesn't have floating point processor, it is necessary to to emulate one in software. This costs flash.

Grumpy_Mike: Read reply #22 again.

I did, Thank you robtillaart, that sums it clearly.

AWOL, unsure what your point is. You're showing more emphasis picking up silly mistakes that actually answering the question... well at least until someone did!? 8)

AWOL:

The float does indeed use 4 bytes of dynamic memory

RAM on the AVR is static, not dynamic.

I was only quoting the compiler - "Global variables use 204 bytes (9%) of dynamic memory"

You're showing more emphasis picking up silly mistakes

Mistakes are mistakes - pointing them out is what I do, that is how we learn. Qualifying them with adjectives is your choice.

AWOL:

You're showing more emphasis picking up silly mistakes

Mistakes are mistakes - pointing them out is what I do, that is how we learn. Qualifying them with adjectives is your choice.

Qualifying them with adjectives is being aware of my own mistakes, without which I would not be able to learn.

But back to the original issue, that was not a mistake, it was a direct question and therefore i would rather have a a direct answer.

I really appreciate your collaboration, don't get me wrong, but just want to make clear that in this case I asked why the size of the sketch was being increased by x amount, which was clearly [u]more than the variable itself[/u] and therefore, pointing the fact that a variable uses an x amount of memory does not add clarification to the original question.