floating point on delay function

Halo,

What is the result of the following function?

delayMicroseconds(2.326);

Is the board can read 0.232?

Thanks!

What is the result of the following function?

Why not look at the documentation of the delayMicroseconds function?
Why not consider that the processor has a minimum instruction cycle time of 0.0625us?

Regardless of the answer, I'm very very curious to know what application you have that's concerned with 1/1000 of a microsecond.

Delay less than microsecond can be achieved with NOP instruction on ATmega (1 cycle time).
In C language like this:

/* no operation (NOP) CPU instruction */
#ifndef _NOP
	#define _NOP()  __asm__ __volatile__("nop")
#endif

void loop()
{
  _NOP();
}

If the CPU frequency is 16MHz, 1 cycle is 0.0625us.

keung0726:
Halo,

What is the result of the following function?

delayMicroseconds(2.326);

Is the board can read 0.232?

Thanks!

To actually answer your question:

Since delayMicroseconds() takes an unsigned int as an argument, your float will be converted to an unsigned int and the function will execute once that conversion is made. In your case, it will be the equivalent of:

delayMicroseconds(2);

because the conversion of a float to an int is simple truncation.

So, since (by reading the link) we also observe:

This function works very accurately in the range 3 microseconds and up. We cannot assure that delayMicroseconds will perform precisely for smaller delay-times.

you realize now that you cannot depend on a value this small to be accurate/meaningful. This has to do with the number of instructions per millisecond on your arduino…

Of course you could have always just tried it!

void setup() 
{
  Serial.begin(115200);
  unsigned int start = micros();
  delayMicroseconds(2.345);
  unsigned int end = micros();
  Serial.println(end - start);  // bear in mind that these calls to Serial are slow....
  Serial.println(static_cast<unsigned int>(2.345));
}

void loop() 
{
  // put your main code here, to run repeatedly:

}

@BulldogLowell
K+ for your approach. I like the explanation you offer. Sometime it is not easy to keep the right direction.

BulldogLowell:

void setup() 

{
  Serial.begin(115200);
  unsigned int start = micros();
  delayMicroseconds(2.345);
  unsigned int end = micros();
  Serial.println(end - start);  // bear in mind that these calls to Serial are slow…
  Serial.println(static_cast(2.345));
}

void loop()
{
  // put your main code here, to run repeatedly:

}

Bear in mind that micros has a 4 μs resolution so such code won’t prove much. Try doing it inside a loop.

maybe you didn't read my whole post...

BulldogLowell:
So, since (by reading the link) we also observe:

... quote removed ...

you realize now that you cannot depend on a value this small to be accurate/meaningful. This has to do with the number of instructions per millisecond on your arduino...

I didn't set out to prove anything, I just answered the OP's question. Reading the link was part of the answer!