question regard W&R float in flash

I have a large float vector stored in flash like this:

const float filter[105] PROGMEM = {....data here....}

I googled online and people said I have to call the elements like

pgm_read_float_near(&filter[0])

I tried to directly call the elements as

filter[0]

couldn't see any difference. of course I can only see 2 digits after decimal point by sending the float value through Serial.print. but if I multiply it by 1000000, the rest digits will show up.

So which is the right way to do it please?

To print more digits of a float you can supply a second argument to print.

float val = 3.14159265

Serial.print(val);   // prints 2 digits after decimal
Serial.print(val, 5);  // prints 5 digits after the decimal

Delta_G:
To print more digits of a float you can supply a second argument to print.

float val = 3.14159265

Serial.print(val);  // prints 2 digits after decimal
Serial.print(val, 5);  // prints 5 digits after the decimal

thanks!

learned something new.

and my question, if I can read the same number out, can I directly call the variable ? or do I have to use the syntax from the reference as "pgm_read_float_near(&filter[0])"

gzanta:
thanks!

learned something new.

and my question, if I can read the same number out, can I directly call the variable ? or do I have to use the syntax from the reference as "pgm_read_float_near(&filter[0])"

passing by reference (i.e. pgm_read_float_near(&filter[0])) allows you to modify the variable in the function that to which the variable is passed.

passing by value (i.e pgm_read_float_near(filter[0]), the function cannot make changes to the variable that is passed; it (like the name suggests) receives the value stored at filter[0] in your example.

@Bulldog - This isn't pass by reference. That would be & in the function prototype. In this case the pgm_read_float_near function needs a pointer to float. The & is to get the pointer to filter[0].

right!

I thought I was looking at function prototypes

whoops!