Benchmarks

This section describes a range of performance benchmarks that have been run comparing this library with the standard library, and how to run your own benchmarks if required.

The values in the ratio column are how many times longer running a specific operation takes in comparison to the same operation with a double.

On nearly all platforms, there is hardware support for binary floating point math, so we are comparing hardware to software runtimes; Decimal will be slower
Both the results from Intel and GCC types are from very close, but not identical benchmark routines since they are written in C instead of C++. We assume they are close enough, and the differences between the C and C++ compilers are small enough, for fair comparison

How to run the Benchmarks

To run the benchmarks yourself, navigate to the test folder and define BOOST_DECIMAL_RUN_BENCHMARKS when running the tests. An example on Linux with b2: ../../../b2 cxxstd=20 toolset=gcc-13 define=BOOST_DECIMAL_RUN_BENCHMARKS benchmarks -a release, or ../../../b2 cxxstd=20 toolset=gcc-13 define=BOOST_DECIMAL_RUN_BENCHMARKS=1,BOOST_DECIMAL_BENCHMARK_CHARCONV=1 benchmarks -a release to also run the <charconv> benchmarks

To run the GCC benchmarks you can use the following command: gcc benchmark_libdfp.c -O3 -std=c17 followed by: ./a.out

To run the Intel benchmarks you will need both the Intel Compiler, and the library. You can the use the following command: icx benchmark_libbid.c -O3 $PATH_TO_LIBBID/libbid.a -std=c17 followed by: ./a.out You can also use gcc instead of icx. On windows the command is similarly: cl benchmark_libbid.c /O2 /std:c17 ..\PATH_TO_LIBBID\cl000libbid.lib, followed by: .\benchmark_libbid.exe.

The Intel benchmarks can only be run on one of their supported architectures: IA-32, IA-64, and Intel x64

Methodology

Comparisons

The benchmark for comparisons generates a random vector containing 20,000,000 elements and does operations >, >=, <, <=, ==, and != between vec[i] and vec[i + 1]. This is repeated 5 times to generate stable results.

Basic Mathematical Operations

The benchmark for these operations generates a random vector containing 20 million elements and does operations +, -, *, / between vec[i] and vec[i + 1]. This is repeated five times to generate stable results.

<charconv>

Parsing and serializing number exactly is one of the key features of decimal floating point types, so we must compare the performance of <charconv>. For all the following the results compare we compare against STL provided <charconv> for 20 million conversions. Since <charconv> is fully implemented in software for each type the performance gap between built-in float and double vs decimal32_t and decimal64_t is significantly smaller (or the decimal performance is better) than the hardware vs. software performance gap seen above for basic operations.

To run these benchmarks yourself, you will need a compiler with complete implementation of <charconv> and to run the benchmarks under C++17 or higher. At the time of writing, this is limited to:

  • GCC 11 or newer

  • MSVC 19.24 or newer

These benchmarks are automatically disabled if your compiler does not provide feature complete <charconv> or if the language standard is set to C++14.

x64 Linux

Run on the GitHub Actions ubuntu-latest runner: the GCC tables use GCC 14, and the Intel Compiler tables use the Intel oneAPI compiler (icpx for the Boost.Decimal types and icx for the Intel libbid types).

Comparisons

Intel Compiler:

Type

Runtime (us)

Ratio to double

float

111,124

0.447

double

248,802

1.000

decimal32_t

2,123,197

8.534

decimal64_t

2,665,076

10.712

decimal128_t

7,158,255

28.771

decimal_fast32_t

910,669

3.660

decimal_fast64_t

1,002,574

4.030

decimal_fast128_t

1,011,988

4.067

Intel BID_UINT32

3,220,763

12.945

Intel BID_UINT64

4,023,186

16.170

Intel BID_UINT128

4,635,399

18.631

GCC:

Type

Runtime (us)

Ratio to double

float

85,168

1.059

double

80,442

1.000

decimal32_t

1,654,213

20.564

decimal64_t

1,348,016

16.758

decimal128_t

8,984,182

111.685

decimal_fast32_t

856,606

10.649

decimal_fast64_t

825,377

10.261

decimal_fast128_t

835,934

10.392

GCC _Decimal32

1,309,079

16.274

GCC _Decimal64

752,050

9.349

GCC _Decimal128

1,475,067

18.337

Intel BID_UINT32

5,788,361

71.957

Intel BID_UINT64

7,917,538

98.425

Intel BID_UINT128

7,946,739

98.788

Addition

Intel Compiler:

Type

Runtime (us)

Ratio to double

float

114,987

0.998

double

115,164

1.000

decimal32_t

2,089,967

18.148

decimal64_t

1,740,472

15.113

decimal128_t

4,184,437

36.335

decimal_fast32_t

1,458,413

12.664

decimal_fast64_t

1,138,832

9.889

decimal_fast128_t

1,243,561

10.798

Intel BID_UINT32

1,838,514

15.964

Intel BID_UINT64

2,981,101

25.886

Intel BID_UINT128

3,024,495

26.263

GCC:

Type

Runtime (us)

Ratio to double

float

89,362

0.999

double

89,435

1.000

decimal32_t

1,917,872

21.444

decimal64_t

1,937,493

21.664

decimal128_t

4,950,077

55.348

decimal_fast32_t

1,121,823

12.543

decimal_fast64_t

2,163,063

24.186

decimal_fast128_t

1,876,894

20.986

GCC _Decimal32

5,135,740

57.424

GCC _Decimal64

3,691,869

41.280

GCC _Decimal128

5,882,148

65.770

Intel BID_UINT32

5,254,741

58.755

Intel BID_UINT64

6,382,980

71.370

Intel BID_UINT128

4,396,855

49.163

Subtraction

Intel Compiler:

Type

Runtime (us)

Ratio to double

float

114,881

0.997

double

115,264

1.000

decimal32_t

2,075,105

18.003

decimal64_t

1,845,795

16.014

decimal128_t

3,991,074

34.626

decimal_fast32_t

1,559,508

13.530

decimal_fast64_t

1,291,654

11.206

decimal_fast128_t

1,448,430

12.566

Intel BID_UINT32

2,854,390

24.764

Intel BID_UINT64

2,855,248

24.771

Intel BID_UINT128

3,079,690

26.719

GCC:

Type

Runtime (us)

Ratio to double

float

638,569

0.998

double

639,634

1.000

decimal32_t

1,898,022

2.967

decimal64_t

2,056,412

3.215

decimal128_t

4,365,732

6.825

decimal_fast32_t

1,239,682

1.938

decimal_fast64_t

2,365,119

3.698

decimal_fast128_t

3,658,821

5.720

GCC _Decimal32

3,336,704

5.217

GCC _Decimal64

2,188,201

3.421

GCC _Decimal128

5,438,682

8.503

Intel BID_UINT32

6,432,427

10.056

Intel BID_UINT64

6,754,523

10.560

Intel BID_UINT128

5,376,552

8.406

Multiplication

Intel Compiler:

Type

Runtime (us)

Ratio to double

float

115,053

0.998

double

115,323

1.000

decimal32_t

3,541,867

30.713

decimal64_t

3,945,021

34.208

decimal128_t

13,177,002

114.262

decimal_fast32_t

2,440,833

21.165

decimal_fast64_t

3,178,854

27.565

decimal_fast128_t

11,590,562

100.505

Intel BID_UINT32

2,039,237

17.683

Intel BID_UINT64

4,052,067

35.137

Intel BID_UINT128

13,813,267

119.779

GCC:

Type

Runtime (us)

Ratio to double

float

88,078

1.002

double

87,943

1.000

decimal32_t

3,438,455

39.099

decimal64_t

4,165,490

47.366

decimal128_t

17,431,447

198.213

decimal_fast32_t

1,952,643

22.204

decimal_fast64_t

4,379,301

49.797

decimal_fast128_t

18,432,685

209.598

GCC _Decimal32

4,340,457

49.355

GCC _Decimal64

4,180,519

47.537

GCC _Decimal128

11,909,973

135.428

Intel BID_UINT32

5,745,479

65.332

Intel BID_UINT64

9,552,169

108.618

Intel BID_UINT128

33,858,419

385.004

Division

Intel Compiler:

Type

Runtime (us)

Ratio to double

float

117,693

0.877

double

134,273

1.000

decimal32_t

3,761,435

28.013

decimal64_t

3,914,687

29.155

decimal128_t

10,833,760

80.685

decimal_fast32_t

2,649,447

19.732

decimal_fast64_t

3,228,463

24.044

decimal_fast128_t

7,847,454

58.444

Intel BID_UINT32

2,780,735

20.710

Intel BID_UINT64

5,350,872

39.851

Intel BID_UINT128

13,966,510

104.016

GCC:

Type

Runtime (us)

Ratio to double

float

105,875

0.621

double

170,445

1.000

decimal32_t

3,313,682

19.441

decimal64_t

3,896,799

22.863

decimal128_t

11,516,236

67.566

decimal_fast32_t

2,809,783

16.485

decimal_fast64_t

3,114,135

18.271

decimal_fast128_t

10,499,827

61.602

GCC _Decimal32

8,350,157

48.990

GCC _Decimal64

5,014,533

29.420

GCC _Decimal128

17,367,305

101.894

Intel BID_UINT32

6,228,856

36.545

Intel BID_UINT64

10,105,630

59.290

Intel BID_UINT128

27,516,263

161.438

from_chars

General Format

Type

Runtime (us)

Ratio to double

float

2,437,788

0.917

double

2,657,378

1.000

decimal32_t

3,131,251

1.178

decimal64_t

4,291,891

1.615

decimal128_t

9,911,474

3.730

decimal_fast32_t

4,737,095

1.783

decimal_fast64_t

4,404,334

1.657

decimal_fast128_t

10,414,943

3.919

Scientific Format

Type

Runtime (us)

Ratio to double

float

2,506,008

0.954

double

2,625,702

1.000

decimal32_t

3,008,653

1.146

decimal64_t

4,180,192

1.592

decimal128_t

9,712,229

3.699

decimal_fast32_t

4,142,588

1.578

decimal_fast64_t

4,118,461

1.569

decimal_fast128_t

8,772,097

3.341

to_chars

General Format Shortest Precision

Type

Runtime (us)

Ratio to double

float

2,920,036

0.850

double

3,436,919

1.000

decimal32_t

4,136,631

1.204

decimal64_t

4,318,996

1.257

decimal128_t

14,624,180

4.255

decimal_fast32_t

4,752,219

1.383

decimal_fast64_t

4,382,014

1.275

decimal_fast128_t

17,350,588

5.048

General Format 6 digits Precision

Type

Runtime (us)

Ratio to double

float

5,541,073

0.969

double

5,716,626

1.000

decimal32_t

3,527,433

0.617

decimal64_t

4,125,772

0.722

decimal128_t

6,967,211

1.219

decimal_fast32_t

3,654,219

0.639

decimal_fast64_t

3,386,125

0.592

decimal_fast128_t

6,018,439

1.053

Scientific Format Shortest Precision

Type

Runtime (us)

Ratio to double

float

2,841,569

0.827

double

3,437,387

1.000

decimal32_t

2,564,053

0.750

decimal64_t

2,856,944

0.831

decimal128_t

12,147,039

3.534

decimal_fast32_t

2,878,507

0.837

decimal_fast64_t

2,933,273

0.853

decimal_fast128_t

15,010,374

4.367

Scientific Format 6 digits Precision

Type

Runtime (us)

Ratio to double

float

4,896,523

0.958

double

5,112,924

1.000

decimal32_t

2,542,237

0.497

decimal64_t

3,119,552

0.610

decimal128_t

4,811,741

0.941

decimal_fast32_t

2,890,023

0.565

decimal_fast64_t

2,956,466

0.578

decimal_fast128_t

5,476,431

1.071

x32 Linux

Run on the GitHub Actions ubuntu-latest runner built 32-bit (-m32) with GCC 14.

Comparisons

Type

Runtime (us)

Ratio to double

float

218,958

0.998

double

219,360

1.000

decimal32_t

1,737,544

7.921

decimal64_t

2,641,269

12.041

decimal128_t

12,785,193

58.284

decimal_fast32_t

810,359

3.694

decimal_fast64_t

973,523

4.438

decimal_fast128_t

1,668,334

7.605

GCC _Decimal32

2,008,198

9.155

GCC _Decimal64

1,371,538

6.252

GCC _Decimal128

3,599,488

16.409

Intel BID_UINT32

7,259,612

33.095

Intel BID_UINT64

13,689,027

62.404

Intel BID_UINT128

14,084,425

64.207

Addition

Type

Runtime (us)

Ratio to double

float

405,897

1.024

double

396,331

1.000

decimal32_t

1,939,282

4.893

decimal64_t

3,260,021

8.226

decimal128_t

10,051,940

25.362

decimal_fast32_t

1,560,823

3.938

decimal_fast64_t

2,316,658

5.845

decimal_fast128_t

4,063,567

10.253

GCC _Decimal32

8,992,119

22.688

GCC _Decimal64

6,286,686

15.862

GCC _Decimal128

11,553,019

29.150

Intel BID_UINT32

10,155,501

25.624

Intel BID_UINT64

11,869,147

29.948

Intel BID_UINT128

9,837,845

24.822

Subtraction

Type

Runtime (us)

Ratio to double

float

406,120

1.016

double

399,739

1.000

decimal32_t

1,992,724

4.985

decimal64_t

3,604,077

9.016

decimal128_t

8,985,637

22.479

decimal_fast32_t

1,574,896

3.940

decimal_fast64_t

2,594,218

6.490

decimal_fast128_t

4,758,754

11.905

GCC _Decimal32

6,535,773

16.350

GCC _Decimal64

5,228,611

13.080

GCC _Decimal128

10,506,473

26.283

Intel BID_UINT32

11,342,434

28.375

Intel BID_UINT64

12,277,171

30.713

Intel BID_UINT128

10,883,496

27.227

Multiplication

Type

Runtime (us)

Ratio to double

float

405,436

1.014

double

399,698

1.000

decimal32_t

3,588,771

8.979

decimal64_t

16,292,591

40.762

decimal128_t

59,885,317

149.826

decimal_fast32_t

2,185,862

5.469

decimal_fast64_t

15,107,474

37.797

decimal_fast128_t

61,364,608

153.527

GCC _Decimal32

10,260,711

25.671

GCC _Decimal64

10,233,556

25.603

GCC _Decimal128

24,483,677

61.255

Intel BID_UINT32

10,013,583

25.053

Intel BID_UINT64

20,791,232

52.017

Intel BID_UINT128

73,505,671

183.903

Division

Type

Runtime (us)

Ratio to double

float

232,240

1.001

double

231,965

1.000

decimal32_t

3,783,007

16.309

decimal64_t

13,399,342

57.764

decimal128_t

38,156,153

164.491

decimal_fast32_t

3,558,170

15.339

decimal_fast64_t

12,932,823

55.753

decimal_fast128_t

32,450,569

139.894

GCC _Decimal32

19,020,688

81.998

GCC _Decimal64

14,541,743

62.689

GCC _Decimal128

49,702,372

214.267

Intel BID_UINT32

11,776,038

50.766

Intel BID_UINT64

24,981,386

107.695

Intel BID_UINT128

82,414,494

355.288

x64 Windows

Run on the GitHub Actions windows-latest runner using MSVC in release mode.

Comparisons

Type

Runtime (us)

Ratio to double

float

267,312

0.949

double

281,801

1.000

decimal32_t

2,069,413

7.344

decimal64_t

3,341,678

11.858

decimal128_t

13,633,699

48.381

decimal_fast32_t

1,379,251

4.894

decimal_fast64_t

1,774,931

6.299

decimal_fast128_t

1,082,371

3.841

Intel BID_UINT32

6,041,898

21.440

Intel BID_UINT64

7,528,030

26.714

Intel BID_UINT128

12,758,626

45.275

Addition

Type

Runtime (us)

Ratio to double

float

84,247

0.908

double

92,784

1.000

decimal32_t

2,911,923

31.384

decimal64_t

3,249,001

35.017

decimal128_t

7,632,232

82.258

decimal_fast32_t

2,220,725

23.934

decimal_fast64_t

3,177,791

34.249

decimal_fast128_t

2,246,796

24.215

Intel BID_UINT32

6,235,650

67.206

Intel BID_UINT64

5,979,724

64.448

Intel BID_UINT128

7,093,720

76.454

Subtraction

Type

Runtime (us)

Ratio to double

float

554,188

1.010

double

548,707

1.000

decimal32_t

3,221,102

5.870

decimal64_t

3,613,448

6.585

decimal128_t

7,409,670

13.504

decimal_fast32_t

2,644,884

4.820

decimal_fast64_t

3,817,024

6.956

decimal_fast128_t

2,867,294

5.226

Intel BID_UINT32

6,533,652

11.907

Intel BID_UINT64

5,760,666

10.499

Intel BID_UINT128

9,366,140

17.069

Multiplication

Type

Runtime (us)

Ratio to double

float

84,930

0.904

double

93,926

1.000

decimal32_t

4,309,301

45.880

decimal64_t

6,482,512

69.017

decimal128_t

19,776,429

210.553

decimal_fast32_t

3,243,070

34.528

decimal_fast64_t

7,399,381

78.779

decimal_fast128_t

18,226,008

194.046

Intel BID_UINT32

5,035,552

53.612

Intel BID_UINT64

10,404,515

110.774

Intel BID_UINT128

57,034,486

607.228

Division

Type

Runtime (us)

Ratio to double

float

104,422

0.681

double

153,241

1.000

decimal32_t

4,391,552

28.658

decimal64_t

5,114,360

33.375

decimal128_t

15,204,345

99.219

decimal_fast32_t

4,702,937

30.690

decimal_fast64_t

5,209,485

33.995

decimal_fast128_t

9,286,117

60.598

Intel BID_UINT32

5,488,896

35.819

Intel BID_UINT64

10,099,622

65.907

Intel BID_UINT128

38,082,318

248.513

from_chars

General Format

Type

Runtime (us)

Ratio to double

float

7,892,780

0.457

double

17,282,516

1.000

decimal32_t

3,544,166

0.205

decimal64_t

5,095,337

0.295

decimal128_t

18,972,286

1.098

decimal_fast32_t

5,182,044

0.300

decimal_fast64_t

6,344,823

0.367

decimal_fast128_t

34,476,545

1.995

Scientific Format

Type

Runtime (us)

Ratio to double

float

7,839,980

0.454

double

17,282,516

1.000

decimal32_t

3,393,317

0.196

decimal64_t

4,924,720

0.285

decimal128_t

29,240,187

1.692

decimal_fast32_t

5,092,334

0.295

decimal_fast64_t

6,341,230

0.367

decimal_fast128_t

34,519,610

1.997

to_chars

General Format Shortest Precision

Type

Runtime (us)

Ratio to double

float

3,181,029

0.826

double

3,852,857

1.000

decimal32_t

5,242,934

1.361

decimal64_t

5,586,541

1.450

decimal128_t

13,955,214

3.622

decimal_fast32_t

6,053,804

1.571

decimal_fast64_t

7,957,278

2.065

decimal_fast128_t

20,202,107

5.243

General Format 6 digits Precision

Type

Runtime (us)

Ratio to double

float

6,111,231

0.949

double

6,433,885

1.000

decimal32_t

4,605,311

0.716

decimal64_t

4,742,497

0.737

decimal128_t

12,372,901

1.923

decimal_fast32_t

4,716,827

0.733

decimal_fast64_t

4,861,975

0.756

decimal_fast128_t

10,779,778

1.675

Scientific Format Shortest Precision

Type

Runtime (us)

Ratio to double

float

3,107,509

0.773

double

4,020,767

1.000

decimal32_t

3,428,517

0.853

decimal64_t

4,095,802

1.019

decimal128_t

11,577,791

2.879

decimal_fast32_t

3,375,975

0.840

decimal_fast64_t

4,427,563

1.101

decimal_fast128_t

13,581,654

3.378

Scientific Format 6 digits Precision

Type

Runtime (us)

Ratio to double

float

4,938,623

0.930

double

5,309,818

1.000

decimal32_t

3,435,843

0.647

decimal64_t

3,682,980

0.694

decimal128_t

9,223,227

1.737

decimal_fast32_t

3,379,702

0.637

decimal_fast64_t

3,892,990

0.733

decimal_fast128_t

10,158,657

1.913

ARM64 Windows

Run on the GitHub Actions windows-11-arm runner using MSVC in release mode.

Comparisons

Type

Runtime (us)

Ratio to double

float

182,631

1.021

double

178,811

1.000

decimal32_t

1,675,672

9.371

decimal64_t

2,204,593

12.329

decimal128_t

8,820,649

49.329

decimal_fast32_t

873,023

4.882

decimal_fast64_t

892,885

4.993

decimal_fast128_t

891,362

4.985

Addition

Type

Runtime (us)

Ratio to double

float

54,458

0.885

double

61,551

1.000

decimal32_t

2,203,310

35.796

decimal64_t

2,235,741

36.323

decimal128_t

5,484,163

89.099

decimal_fast32_t

1,503,891

24.433

decimal_fast64_t

1,996,293

32.433

decimal_fast128_t

2,922,130

47.475

Subtraction

Type

Runtime (us)

Ratio to double

float

54,309

0.904

double

60,063

1.000

decimal32_t

2,344,101

39.027

decimal64_t

2,461,049

40.974

decimal128_t

5,257,033

87.525

decimal_fast32_t

1,875,233

31.221

decimal_fast64_t

2,356,630

39.236

decimal_fast128_t

3,255,466

54.201

Multiplication

Type

Runtime (us)

Ratio to double

float

55,894

0.884

double

63,214

1.000

decimal32_t

3,284,833

51.964

decimal64_t

4,325,658

68.429

decimal128_t

15,701,811

248.391

decimal_fast32_t

2,314,410

36.612

decimal_fast64_t

3,827,303

60.545

decimal_fast128_t

15,460,123

244.568

Division

Type

Runtime (us)

Ratio to double

float

56,253

0.379

double

148,333

1.000

decimal32_t

3,657,033

24.654

decimal64_t

7,237,316

48.791

decimal128_t

16,783,738

113.149

decimal_fast32_t

2,750,815

18.545

decimal_fast64_t

6,732,683

45.389

decimal_fast128_t

14,954,134

100.815

ARM64 macOS

Run using a Macbook pro with M4 Max chipset running macOS Tahoe 26.5.1 and homebrew Clang 22.1.7

Comparisons

Type

Runtime (us)

Ratio to double

float

245,753

1.415

double

173,624

1.000

decimal32_t

2,130,311

12.270

decimal64_t

2,081,778

11.990

decimal128_t

4,986,707

28.721

decimal_fast32_t

1,598,693

9.208

decimal_fast64_t

1,480,876

8.529

decimal_fast128_t

2,026,589

11.672

Addition

Type

Runtime (us)

Ratio to double

float

65,878

0.448

double

147,047

1.000

decimal32_t

2,443,207

16.615

decimal64_t

1,984,135

13.493

decimal128_t

3,190,734

21.699

decimal_fast32_t

1,453,432

9.884

decimal_fast64_t

1,488,265

10.121

decimal_fast128_t

2,090,004

14.213

Subtraction

Type

Runtime (us)

Ratio to double

float

142,634

1.287

double

110,818

1.000

decimal32_t

2,733,591

24.667

decimal64_t

2,206,734

19.913

decimal128_t

3,185,713

28.747

decimal_fast32_t

1,672,704

15.094

decimal_fast64_t

1,611,485

14.542

decimal_fast128_t

1,935,134

17.462

Multiplication

Type

Runtime (us)

Ratio to double

float

72,495

0.574

double

126,312

1.000

decimal32_t

4,025,974

31.873

decimal64_t

4,101,858

32.474

decimal128_t

10,307,655

81.605

decimal_fast32_t

2,720,844

21.541

decimal_fast64_t

3,662,837

28.998

decimal_fast128_t

9,077,818

71.868

Division

Type

Runtime (us)

Ratio to double

float

48,647

0.412

double

118,030

1.000

decimal32_t

4,596,994

38.948

decimal64_t

4,918,310

41.670

decimal128_t

15,939,577

135.047

decimal_fast32_t

2,810,646

23.813

decimal_fast64_t

4,340,941

36.778

decimal_fast128_t

14,494,890

122.807

from_chars

General Format

Type

Runtime (us)

Ratio to double

float

1,882,825

0.990

double

1,901,380

1.000

decimal32_t

3,427,654

1.803

decimal64_t

5,364,564

2.821

decimal128_t

11,752,375

6.181

decimal_fast32_t

4,339,550

2.282

decimal_fast64_t

6,647,959

3.496

decimal_fast128_t

14,010,588

7.369

Scientific Format

Type

Runtime (us)

Ratio to double

float

1,939,033

1.010

double

1,919,671

1.000

decimal32_t

3,411,016

1.777

decimal64_t

5,278,214

2.750

decimal128_t

11,479,704

5.980

decimal_fast32_t

4,299,497

2.240

decimal_fast64_t

6,287,638

3.275

decimal_fast128_t

9,856,122

5.134

to_chars

General Format Shortest Precision

Type

Runtime (us)

Ratio to double

float

2,223,891

0.882

double

2,520,203

1.000

decimal32_t

2,983,523

1.184

decimal64_t

3,348,702

1.329

decimal128_t

8,899,289

3.531

decimal_fast32_t

3,383,567

1.343

decimal_fast64_t

3,436,470

1.364

decimal_fast128_t

12,509,443

4.964

General Format 6 digits Precision

Type

Runtime (us)

Ratio to double

float

4,664,538

0.948

double

4,915,699

1.000

decimal32_t

2,570,339

0.523

decimal64_t

3,309,343

0.673

decimal128_t

5,962,030

1.212

decimal_fast32_t

2,213,792

0.450

decimal_fast64_t

3,067,584

0.624

decimal_fast128_t

6,006,157

1.222

Scientific Format Shortest Precision

Type

Runtime (us)

Ratio to double

float

2,119,538

0.848

double

2,500,900

1.000

decimal32_t

1,757,416

0.703

decimal64_t

2,187,911

0.875

decimal128_t

6,976,380

2.790

decimal_fast32_t

1,739,069

0.695

decimal_fast64_t

2,060,848

0.824

decimal_fast128_t

12,509,443

5.002

Scientific Format 6 digits Precision

Type

Runtime (us)

Ratio to double

float

4,157,977

0.933

double

4,457,878

1.000

decimal32_t

1,764,018

0.395

decimal64_t

2,625,621

0.589

decimal128_t

4,060,487

0.911

decimal_fast32_t

1,728,473

0.388

decimal_fast64_t

2,734,955

0.614

decimal_fast128_t

5,300,774

1.189