# OS_TicksTo*Seconds*

## C Specification

      #include <nitro/os.h>

      OS_TicksToMicroSeconds( tick )
      OS_TicksToMicroSeconds32( tick )

      OS_TicksToMilliSeconds( tick )
      OS_TicksToMilliSeconds32( tick )

      OS_TicksToSeconds( tick )
      OS_TicksToSeconds32( tick )

      (These are all macros.)

## Arguments

tick | Tick Value

## Return Values

The actual time that corresponds to the tick value that is specified in the argument.

## Description

This function obtains the actual time that corresponds to the tick value that is specified in the argument. One tick unit is 1/64 of the system clock.

`OS_TicksToMicroSeconds*()` converts the tick value to microseconds.
`OS_TicksToMilliSeconds*()` converts the tick value to milliseconds.
`OS_TicksToSeconds*()` converts the tick value to seconds.
These functions are all defined as macros.

Functions with `32` in their names conduct 32-bit internal calculations. Those without `32` conduct 64-bit calculations. 32-bit versions handle smaller values than 64-bit versions, so they cannot always return correct results because of overflow. However, when there is no overflow, they have the advantage of keeping the code smaller, making operating speed faster. However, since the degree of difference is not that great, and to prevent bugs, we recommend you use functions that do not include `32` in the name. Furthermore, when a constant is made into an argument, it is calculated just before compiling and the resulting value is also a constant.

When operating in 32-bit mode, be careful of overflow. Values that will cause overflow are in the following diagram.

Function Name | This value or less is OK. | Beyond this value is not allowed.
--- | --- | ---
`OS_TicksToSeconds32()` | 67108863 (tick units) This value is suitable for about 2 seconds. | 67108864 (tick units)
`OS_TicksToMilliSeconds32()` | 67108863 (tick units) This value is suitable for about 2002 milliseconds=2 seconds. | 67108864 (tick units)
`OS_TicksToMicroSeconds32()` | 67108 (tick units) This value is suitable for about 2002 microseconds=0.000002 seconds. | 67109 (tick units)

Further, values that overflow in 64-bit operation are: about 2.8 x 10 to the 14th tick units (about 99 days) for `OS_TicksToMicroSeconds*()`, and 2.8 x 10 to the 17th tick units (about 272 years) for `OS_TicksToMilliSeconds*()` and `OS_TicksToSeconds*()`.

## See Also

`OS_InitTick, OS_GetTick
OS_SetAlarm, OS_SetPeriodicAlarm
OS_*SecondsToTicks
`

## Revision History

10/07/2005 Changed differences between 32-bit and 64-bit operation.
10/06/2005 Considered and changed overflow for 32-bit and 64-bit operation.
02/25/2004 Changed Count to Tick.
02/24/2004 Initial version.

CONFIDENTIAL