Skip to main content
Glama

Encode number

encode_number
Read-only

Encode a decimal or special value such as Infinity or NaN into a chosen floating-point or integer format, returning binary, hex, and component breakdown.

Instructions

Encode a decimal number (or special value like Infinity / NaN) into a specified floating-point or integer format. Returns binary, hex, and component breakdown.

Input Schema

NameRequiredDescriptionDefault
valueYesThe value to encode. Accepts a number, hex string (e.g. "0xFF"), or keyword ("infinity", "-infinity", "nan").
formatYesFormat preset key (e.g. "fp32", "int8") or custom format object. For floating-point: { signBits, exponentBits, mantissaBits, bias?, hasInfinity?, hasNaN?, hasSubnormals? }. For integer: { bits, signed, fractionBits?, symmetric? }.
overflowModeNoWhat an out-of-range magnitude becomes. "overflow" produces Infinity (or NaN when the format has no Infinity); "saturate" clamps to the largest finite value. Omit to use the per-format default (overflow for formats with Infinity, saturate otherwise). IEEE 754 §7.4 directed rounding still clamps finite overflow regardless of this setting.
roundingModeNoRounding mode for encoding the value. Options: "tiesToEven" (default, IEEE 754), "tiesToAway", "towardZero", "towardPositive", "towardNegative".

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already establish readOnlyHint=true, and the description usefully states the return shape ('binary, hex, and component breakdown'), which matters because there is no output schema. Detailed behavioral semantics (overflow defaults, IEEE 754 directed-rounding clamping) live in the schema rather than the description, so it adds context without contradicting anything.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, no filler: the action and scope come first, the return value second. Every sentence earns its place and nothing is repeated from the schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a deterministic read-only computation tool with a fully documented schema, the description covers both purpose and output shape, which compensates for the missing output schema. Only minor gaps remain, such as what happens on an invalid format or value.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so every parameter including overflowMode and roundingMode is already fully documented in the schema. The description only echoes that a format is needed and does not add syntax or interpretation beyond the schema; baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description gives a specific verb + resource ('Encode a decimal number ... into a specified floating-point or integer format') and even enumerates the accepted input categories (number, Infinity/NaN). It implicitly contrasts with decode_bits as the inverse operation, but never names a sibling, so it falls short of a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is only implied — an agent can infer 'use this when you have a value and a format and want its bits'. There is no explicit when-to-use / when-not guidance and no mention of the closely related siblings convert_format or decode_bits, which is a real gap for a conversion-family tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.