承接 felixdorn/sey 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

felixdorn/sey

Composer 安装命令:

composer require felixdorn/sey

包简介

Sey is a powerful math interpreter with arbitrary-precision.

README 文档

README

The word Sey on a blue background

Sey

Tests Formats Version Total Downloads License

Sey, pronounce say, is a powerful math interpreter with arbitrary-precision.

Installation

Requires PHP 8.0.0+ and the bcmath extension

You can install the package via composer:

composer require felixdorn/sey

Usage

Sey::parse('(0.5 + 0.5) / 3)'); // 0.3333333333333333
// or
sey('a / b', ['a' => 1, 'b' => 2]); // 0.5

Precision

By default, the maximum floating precision is 16.

You may change it:

\Felix\Sey\Sey:precision(32);

Syntax

It's just math.

1 + 2
2 - 3
3 * 4
4 / 5
5 % 6
6 ^ 7
7 * (8 + 9)
sqrt(10)
powmod(11)
11(12 - 13)
(14 + 15)^16
!(5)
pi()

Variables

You can not define variables in your code but you can pass them at compile-time.

Sey::parse('2 * r * pi', [
    'r' => 10,
    'pi' => 3.1415
]);

Functions

  • sqrt: bcsqrt

  • powmod: bcpowmod

  • pi(): custom bcpi function

    This function returns pi with your defined precision up to 999 digits.

  • !(n): custom bcfact function

    This computes n!, if you need to do it really quickly, you should probably use a lookup table.

Custom functions

You can override built-ins functions.

Sey::define('!', function (int $n, /* as many arguments as you want */) {
    return $factorials[$n] ?? bcfact($n);
});

The function name must match the following regex [a-z_A-Z!]+[a-z_A-Z0-9]*.

So, first character must be a letter or ! followed by any number of letters or numbers.

Tests

composer test

sey was created by Félix Dorn under the MIT license.

felixdorn/sey 适用场景与选型建议

felixdorn/sey 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 12, 最近一次更新时间为 2021 年 11 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 felixdorn/sey 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 felixdorn/sey 我们能提供哪些服务?
定制开发 / 二次开发

基于 felixdorn/sey 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-11-05