Home Help Center

Is there a way to assign NaN in a slice file?

cig1024cig1024 Member Lucas AbelOrganization: PersonalProject: stats generator
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.

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi,

    Welcome to the forum.

    Unfortunately the Slice syntax doesn't support the NaN symbol. Have you considered using an optional value as a workaround?

    Take care,
    Mark
  • cig1024cig1024 Member Lucas AbelOrganization: PersonalProject: stats generator
    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.
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Lucas,
    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.


    Best regards,
    Bernard
  • cig1024cig1024 Member Lucas AbelOrganization: PersonalProject: stats generator
    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!
Sign In or Register to comment.