Skip to content

Add NaNConvertMode to EncOptions for v1.5 #91

Closed
@x448

Description

@x448

NaNConvertMode will determine how to encode NaN and it will override ShortestFloatMode.

These two options are broken for sNaN values until a Go bug in reflect package is fixed golang/go#36400

  • NaNConvertNone (much sad because this is for CTAP2 Canonical CBOR in FIDO2, WebAuthn)
  • NaNConvertPreserveSignal (much sad because this is preferred in RFC 7049bis Draft 12 when protocols don't want to use 0x7e00 for every NaN value)

Complete list of options are:

  • NaNConvertNone: never modify or convert NaN to other representations (float64 NaN stays float64, etc. even if it can use float16 without losing any bits)
  • NaNConvertPreserveSignal: convert to smallest form that preserves value (signal status + payload) as described in RFC 7049bis Draft 12
  • NaNConvert7e00: always encode to 0xf97e00 (CBOR float16 = 0x7e00)
  • NaNConvertQuiet: always force quiet bit = 1 and shortest form that preserves NaN payload

EDIT: shortened option names and mention specific options affected by Go issue 36400 and make it clear this overrides ShortestFloatMode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions