0

Is it possible to store a NaN in a property list file. I tried:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
     <integer>nan</integer>
</array>
</plist>

But Xcode was not able to phrase the file. Any thoughts?

Monolo
  • 18,205
  • 17
  • 69
  • 103
jcb344
  • 323
  • 5
  • 16

2 Answers2

3

Floats or doubles can be NaNs, but an integer can not.

Also not sure if you can store it in a plist file.

However, if you use NSUInteger for your integer, you can use a predefined marker like NSNotFound, or you can define your own value that you want to reserve for the purpose.

Monolo
  • 18,205
  • 17
  • 69
  • 103
  • If you codes the plist by hand (instead of writing it to file in code), type the value -1. NSNotFound is defined as -1, or the same bit pattern as the largest possible unsigned integer. – Nicolas Miari Jun 16 '12 at 06:56
2

Yes, for example a dictionary with a NaN value for the key "A_NaN_Value":

<dict>
   <key>A_NaN_Value</key>
   <real>nan</real>
</dict>
CRD
  • 52,522
  • 5
  • 70
  • 86