std.math
API summary (generated from the Beans source by npm run coverage): 2 package functions.
std.math হলো Beans দিয়ে লেখা integer helper-এর একটা ছোট প্যাকেজ। সোর্স পড়ুন
stdlib/std/math/math.b-তে।
import std.mathpub fn clamp(value: int, low: int, high: int) -> intpub fn gcd(a: int, b: int) -> intclampvalue-কে জোর করে[low, high]inclusive range-এর ভেতর নিয়ে আসে।valueযদিlow-এর নিচে হয় তাহলেlowফেরত দেয়,high-এর উপরে হলেhigh, আর নয়তোvalueনিজেই।gcdহলো greatest common divisor। এটাaআরb-এর absolute value-এর উপর Euclid-এর algorithm চালায়, তাই ইনপুটের চিহ্ন কোনো ব্যাপার না।gcd(0, 0)হলো0।
import std.ioimport std.math
fn main() { io.println(math.clamp(15, 0, 10)) // 10 io.println(math.clamp(-3, 0, 10)) // 0 io.println(math.gcd(12, 18)) // 6 io.println(math.gcd(0, 0)) // 0}আরও দেখুন
“আরও দেখুন” সেকশন- Numbers and decimal — integer আর float type আর তাদের নিজস্ব method।