Read What Every Programmer Should Know About Floating-Point Arithmetic and this is especially curious Comparison. I used to think that abs(a-b) < 0.00001 is good enough way to compare floats.

It bugs me a lot that in Xcode there’s no way to show memory area formatted to some basic types like float. E.g. I have dynamic array of floats on Objective-C float *file_contents. What I can do is examine contents of pointer and contents of pointee:

Context menu of pointer variable has item ‘View Memory of “*ppointer_variable”’:

.

But it shows only raw bytes along with textual representation:

Which helps very little in case of array of floats. The only way is to use lldb command like memory read -t float -c50 \file_contents` where -t specifies type and -c count of values to show. memory read -ff -c10 `file_contents` produces same results, where -f specifies format. And there's even shortcut x/10f file_contents! Good to remember that help memory read` and help ‘help x’ work in debugger console in Xcode.

And actually there’s one more way of doing the same - casting the pointer to a pointer-to-array and use p lldb command. p *(float(*)[30])file_contents in our case:

One more way - use parray lldb command, parray 50 file_contents will print 50 elements. And if count of elements is variable it could be parray file_size file_contents.