Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"MD041": false,
"MD043": false
}
26 changes: 8 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
[![Gitpod](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/linksplatform/Numbers)
[![Open in GitHub Codespaces](https://img.shields.io/badge/Codespaces-open-blue?logo=github)](https://codespaces.new/linksplatform/Numbers)

[![NuGet Version and Downloads count](https://img.shields.io/nuget/v/Platform.Numbers?label=nuget&style=flat)](https://www.nuget.org/packages/Platform.Numbers)
[![Actions Status](https://github.com/linksplatform/Numbers/workflows/CD/badge.svg)](https://github.com/linksplatform/Numbers/actions?workflow=CD)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/d0f7cbadcfbe43f7b9c732ec8603d974)](https://app.codacy.com/gh/linksplatform/Numbers?utm_source=github.com&utm_medium=referral&utm_content=linksplatform/Numbers&utm_campaign=Badge_Grade_Settings)
[![CodeFactor](https://www.codefactor.io/repository/github/linksplatform/numbers/badge)](https://www.codefactor.io/repository/github/linksplatform/numbers)

# [Numbers](https://github.com/linksplatform/Numbers)
| CI | Packages | Language |
| -- | -------- | -------- |
| [![CD](https://github.com/linksplatform/Numbers/workflows/CD/badge.svg)](https://github.com/linksplatform/Numbers/actions?workflow=CD) | [![NuGet](https://img.shields.io/nuget/v/Platform.Numbers?label=nuget&style=flat)](https://www.nuget.org/packages/Platform.Numbers) | [C#](csharp) |
| [![C++](https://github.com/linksplatform/Numbers/workflows/Deploy%20new%20cpp%20version/badge.svg)](https://github.com/linksplatform/Numbers/actions?workflow=Deploy+new+cpp+version) | [![Conan](https://repology.org/badge/version-for-repo/conancenter/platform.numbers.svg)](https://conan.io/center/platform.numbers) | [C++](cpp) |
| [![Rust](https://github.com/linksplatform/Numbers/workflows/Rust%20CI%2FCD%20Pipeline/badge.svg)](https://github.com/linksplatform/Numbers/actions?workflow=Rust+CI%2FCD+Pipeline) | [![Crates.io](https://img.shields.io/crates/v/platform-num?label=crates.io&style=flat)](https://crates.io/crates/platform-num) | [Rust](rust) |

LinksPlatform's Platform.Numbers Class Library.
# [Numbers](https://github.com/linksplatform/Numbers)

Namespace: [Platform.Numbers](https://linksplatform.github.io/Numbers/csharp/api/Platform.Numbers.html)
LinksPlatform's Platform.Numbers Library.

Forked from: [Konard/LinksPlatform/Platform/Platform.Helpers/Numbers](https://github.com/Konard/LinksPlatform/tree/19902d5c6221b5c93a5e06849de28bb97edac5f8/Platform/Platform.Helpers/Numbers)

NuGet package: [Platform.Numbers](https://www.nuget.org/packages/Platform.Numbers)

## [Documentation](https://linksplatform.github.io/Numbers)
[PDF file](https://linksplatform.github.io/Numbers/csharp/Platform.Numbers.pdf) with code for e-readers.

## Depend on
* [Platform.Converters](https://github.com/linksplatform/Converters)

## Dependent libraries
* [Platform.Unsafe](https://github.com/linksplatform/Unsafe)
* [Platform.Data](https://github.com/linksplatform/Data)
25 changes: 25 additions & 0 deletions changelog.d/20260321_readme_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
bump: patch
---

### Added

- Rust-specific README.md with detailed description,
usage examples, and crate badges
- C# language-specific README.md with namespace docs,
installation, and usage examples
- C++ language-specific README.md with Conan
installation and usage info

### Changed

- Root README.md now uses a badge table for all
language versions (C#, C++, Rust)
- Replaced Gitpod badge with GitHub Codespaces badge
- Updated Cargo.toml readme field to point to
Rust-specific README.md

### Fixed

- Rust crate on crates.io was displaying generic root
README instead of Rust-specific documentation
43 changes: 43 additions & 0 deletions cpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[![Actions Status](https://github.com/linksplatform/Numbers/workflows/Deploy%20new%20cpp%20version/badge.svg)](https://github.com/linksplatform/Numbers/actions?workflow=Deploy+new+cpp+version)

# [Numbers](https://github.com/linksplatform/Numbers) for C++

LinksPlatform's Platform.Numbers Template Library.

Conan package: [platform.numbers](https://conan.io/center/platform.numbers)

## Overview

This library provides header-only numeric utility templates used
throughout the LinksPlatform ecosystem:

- **`Bit`** — Bit manipulation utilities for integral types.

## Installation

Using [Conan](https://conan.io/):

```ini
[requires]
platform.numbers/[latest]
```

Or using CMake directly:

```cmake
add_subdirectory(cpp)
target_link_libraries(your_target PRIVATE Platform.Numbers)
```

## Usage

```cpp
#include <Platform.Numbers.h>

// Use bit operations from Platform.Numbers
```

## Depend on

- [Platform.Interfaces](https://github.com/linksplatform/Interfaces)
(C++ version)
56 changes: 56 additions & 0 deletions csharp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[![NuGet Version and Downloads count](https://img.shields.io/nuget/v/Platform.Numbers?label=nuget&style=flat)](https://www.nuget.org/packages/Platform.Numbers)
[![Actions Status](https://github.com/linksplatform/Numbers/workflows/CD/badge.svg)](https://github.com/linksplatform/Numbers/actions?workflow=CD)

# [Numbers](https://github.com/linksplatform/Numbers) for C\#

LinksPlatform's Platform.Numbers Class Library.

Namespace: [Platform.Numbers](https://linksplatform.github.io/Numbers/csharp/api/Platform.Numbers.html)

NuGet package: [Platform.Numbers](https://www.nuget.org/packages/Platform.Numbers)

## Overview

This library provides helper classes for numeric operations used
throughout the LinksPlatform ecosystem:

- **`Arithmetic`** / **`Arithmetic<T>`** — Generic arithmetic
operations for unconstrained types.
- **`Bit`** / **`Bit<T>`** — Bit manipulation utilities for
generic types.
- **`Math`** / **`Math<T>`** — Mathematical operations
(e.g. `Abs`, `Negate`) for generic types.
- Extension methods: `ArithmeticExtensions`, `BitExtensions`,
`MathExtensions`.

## Installation

```shell
dotnet add package Platform.Numbers
```

## Usage

```csharp
using Platform.Numbers;

// Check if a bit is set
bool isSet = Bit.Get(0b1010, 3); // true

// Partial read from a number
long value = Bit.PartialRead(0xFF00, 8, 8); // 0xFF
```

## [Documentation](https://linksplatform.github.io/Numbers)

[PDF file](https://linksplatform.github.io/Numbers/csharp/Platform.Numbers.pdf)
with code for e-readers.

## Depend on

- [Platform.Converters](https://github.com/linksplatform/Converters)

## Dependent libraries

- [Platform.Unsafe](https://github.com/linksplatform/Unsafe)
- [Platform.Data](https://github.com/linksplatform/Data)
2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ homepage = "https://github.com/linksplatform/Numbers"
description = """
Numbers for linksplatform
"""
readme = "../README.md"
readme = "README.md"
keywords = ["numbers", "linksplatform", "traits"]
categories = ["development-tools"]

Expand Down
100 changes: 100 additions & 0 deletions rust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
[![Crates.io](https://img.shields.io/crates/v/platform-num?label=crates.io&style=flat)](https://crates.io/crates/platform-num)
[![Rust CI/CD Pipeline](https://github.com/linksplatform/Numbers/workflows/Rust%20CI%2FCD%20Pipeline/badge.svg)](https://github.com/linksplatform/Numbers/actions?workflow=Rust+CI%2FCD+Pipeline)
[![Docs.rs](https://docs.rs/platform-num/badge.svg)](https://docs.rs/platform-num)
[![Codecov](https://codecov.io/gh/linksplatform/Numbers/branch/main/graph/badge.svg)](https://codecov.io/gh/linksplatform/Numbers)

# [Numbers](https://github.com/linksplatform/Numbers) for Rust

LinksPlatform's `platform-num` crate — numeric traits and types
for the Links platform.

Crates.io package: [platform-num](https://crates.io/crates/platform-num)

## Overview

This crate provides a set of numeric traits used throughout the
LinksPlatform ecosystem:

- **`Num`** — A base trait combining `PrimInt`, `Default`, `Debug`,
`AsPrimitive<usize>`, and `ToPrimitive`. Implemented for all
primitive integer types.
- **`SignNum`** — Extends `Num` with signed number operations
(`Signed`, `FromPrimitive`). Implemented for signed integer types.
- **`ToSigned`** — Converts unsigned types to their signed
counterparts (e.g. `u32` → `i32`).
- **`MaxValue`** — Provides a `MAX` associated constant for all
primitive integer types.
- **`LinkType`** — A composite trait for types that can be used as
link identifiers: `Num + Unsigned + ToSigned + MaxValue +
FromPrimitive + Debug + Display + Hash + Send + Sync + 'static`.
Implemented for `u8`, `u16`, `u32`, `u64`, and `usize`.

## Installation

Add to your `Cargo.toml`:

```toml
[dependencies]
platform-num = "0.2"
```

## Usage

### Using `LinkType` as a generic constraint

```rust
use platform_num::LinkType;

fn create_link<T: LinkType>(source: T, target: T) -> (T, T) {
(source, target)
}

let link = create_link(1u64, 2u64);
assert_eq!(link, (1u64, 2u64));
```

### Using `ToSigned` for type conversion

```rust
use platform_num::ToSigned;

let unsigned_val: u32 = 42;
let signed_val: i32 = unsigned_val.to_signed();
assert_eq!(signed_val, 42i32);
```

### Using `MaxValue`

```rust
use platform_num::MaxValue;

fn get_max<T: MaxValue>() -> T {
T::MAX
}

assert_eq!(get_max::<u64>(), u64::MAX);
```

### Using `Num` for generic numeric operations

```rust
use platform_num::Num;
use num_traits::AsPrimitive;

fn to_usize<T: Num>(val: T) -> usize {
val.as_()
}

assert_eq!(to_usize(42u32), 42usize);
```

## Depend on

- [num-traits](https://crates.io/crates/num-traits)

## Dependent libraries

- [platform-trees](https://crates.io/crates/platform-trees)
([trees-rs](https://github.com/linksplatform/trees-rs))
- [doublets](https://crates.io/crates/doublets)
([doublets-rs](https://github.com/linksplatform/doublets-rs))
Loading