| Previous | Next |
| D2DERR_UNSUPPORTED_VERSION | D2DERR_WRONG_FACTORY |
D2DERR_BAD_NUMBER
D2DERR_BAD_NUMBER belongs to Direct2D geometry and numeric validation. A numeric input contains NaN, infinity, an invalid range, or another value Direct2D cannot accept. The diagnostic goal for D2DERR_BAD_NUMBER is to identify the first rejecting object and transition, not merely the final high-level symptom.
Locate the first rejecting layer
For D2DERR_BAD_NUMBER, Direct2D geometry processing depends on finite coordinates, valid matrices, closed geometry sinks, fill rules, and tolerances. When D2DERR_BAD_NUMBER is returned, a scanner failure identifies geometry processing, while a bad-number result can be raised by many APIs before rasterization. Preserve the path segments and numeric inputs at the first method that rejects them in the D2DERR_BAD_NUMBER path.
For D2DERR_BAD_NUMBER, inspect the following boundary: coordinates, matrices, opacity, dimensions, rectangles, effect properties, or tolerances at the failing call.
Controlled reproduction
Build the geometry segment by segment with identity transform and moderate coordinates in the D2DERR_BAD_NUMBER path. For D2DERR_BAD_NUMBER, check every sink close result, then add the original transform, tolerance, and extreme values independently.
- For D2DERR_BAD_NUMBER, assert finite values before Direct2D calls.
- When D2DERR_BAD_NUMBER is returned, use identity transforms and unit-sized geometry.
- Add calculations back one at a time in the D2DERR_BAD_NUMBER path.
- For D2DERR_BAD_NUMBER, test overflow and divide-by-zero paths.
Evidence that changes the diagnosis
| Record | Why it matters here |
|---|---|
| Every floating-point argument in hexadecimal or round-trip form | In D2DERR_BAD_NUMBER diagnostics, recording every floating-point argument in hexadecimal or round-trip form ties the HRESULT to the Direct2D geometry and numeric validation boundary rather than to the final visible failure. |
| Source calculation and unit conversion | Comparing source calculation and unit conversion shows whether D2DERR_BAD_NUMBER follows input, object state, or environment. |
| Matrix determinant and rectangle ordering | Preserving matrix determinant and rectangle ordering provides the evidence needed to test this distinction: sCANNER_FAILED can be a downstream geometry-processing failure; BAD_NUMBER directly identifies invalid numeric data. |
| First API that validates or defers the number | For D2DERR_BAD_NUMBER, recording first API that validates or defers the number separates the Direct2D geometry and numeric validation boundary from a later wrapper symptom. |
Comparison tests
| Test | Interpretation | Hold constant |
|---|---|---|
| Same environment, reduced input | If D2DERR_BAD_NUMBER disappears with a smaller faithful case, complexity within Direct2D geometry and numeric validation is implicated. | For D2DERR_BAD_NUMBER, keep every floating-point argument in hexadecimal or round-trip form fixed while simplifying matrix determinant and rectangle ordering. |
| Same input, fresh object generation | If D2DERR_BAD_NUMBER changes after rebuilding state, examine ownership across the caller’s object graph, custom effect or renderer, Direct2D validation layer, backing device, and deferred draw boundary. | For D2DERR_BAD_NUMBER, place source calculation and unit conversion on the timeline of the last successful transition. |
| Same operation on a controlled second path | If D2DERR_BAD_NUMBER follows one environment, the failure is not explained by source data alone. | For D2DERR_BAD_NUMBER, compare adapter and feature level, factory and device generations, target identity, debug-layer output, and thread ownership while preserving first API that validates or defers the number. |
Misleading responses
SCANNER_FAILED can be a downstream geometry-processing failure; BAD_NUMBER directly identifies invalid numeric data. For D2DERR_BAD_NUMBER, do not respond with a universal render-target recreation loop unless the returned status specifically documents device-loss recovery; graph, property, numeric, lifetime, and print-state errors require correcting their contract.
Closure criteria
A correction for D2DERR_BAD_NUMBER should let the operation at the Direct2D geometry and numeric validation boundary complete repeatedly under the original supported conditions. Repeat the control that begins with “Assert finite values before Direct2D calls” and confirm that the following lifecycle step also succeeds. For D2DERR_BAD_NUMBER, keep the original failing sample and one deliberate negative case so fallback cannot be mistaken for repair.
Technical references
When D2DERR_BAD_NUMBER is returned, these references define the public API family, object model, or error list used to interpret this status.
- Microsoft: Direct2D error codes.
- Microsoft: Direct2D API overview.
- Microsoft: Direct2D geometries overview.
- Microsoft: Direct2D devices and device contexts.
Looking for a different code? Search another status or error code.