CardSight 0.1.0
C API reference for the CardSight firmware and application
Loading...
Searching...
No Matches
size.h File Reference

Capacity display in the decimal units a card is sold in: 1 kB is 1000 bytes, so a 32 GB card reads "32 GB" rather than "29.7 GiB". More...

#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Functions

void format_capacity (uint64_t bytes, char *buffer, size_t size)
 Write a decimal capacity into a buffer.

Detailed Description

Capacity display in the decimal units a card is sold in: 1 kB is 1000 bytes, so a 32 GB card reads "32 GB" rather than "29.7 GiB".

Function Documentation

◆ format_capacity()

void format_capacity ( uint64_t bytes,
char * buffer,
size_t size )

Write a decimal capacity into a buffer.

Picks TB, GB, MB, kB or B from the magnitude and rounds to the nearest whole unit, so a 32 GB card reads "32 GB" and a 512 MB one "512 MB".

Parameters
[in]bytesCapacity in bytes.
[out]bufferDestination string.
[in]sizeSize of buffer in bytes; nothing is written when zero.