This forum has been archived. Please start a
new discussion on GitHub
Is there a way to assign NaN in a slice file?
Is there a way to default the value of a float/double in a slice file to NaN? We seem to be able to pass NaN back and forth between platforms just fine, but we were hoping to be able to default certain values to NaN like we assign other defaults.
Welcome to the forum.
Unfortunately the Slice syntax doesn't support the NaN symbol. Have you considered using an optional value as a workaround?
Thanks for the suggestion!
What I have done for now (which I'm sure you don't recommend) is use a placeholder value for the slice files and then replace of all those values with the language specific definition for NaN (via sed commands). We'll probably loop back and try the method of making these fields sequences, as described in your documentation.
We'll probably loop back and try the method of making these fields sequences
This was the old way to model optional values, before we added direct support for optional data members and parameters in Ice 3.5. See the
Ice 3.5 Release Notes
If you convert your float/double data member to an optional float/double data member (with the new optional(tag) feature), then its default value would be "not set", which could be more appropriate here.
I am only on 3.4.2 right now, so that explains why I don't see that. I'll try upgrading to 3.5. Thanks!