Fixed-point math for Bitcoin Script

Overview

bsv-fixmath

Fixed-point implementations of exp, log, root and pow for Bitcoin SV. This repo contains two equivalent implementations, one in Typescript and one in sCrypt that compiles to Bitcoin Script.

Install with npm install bsv-fixmath.

Getting started

Convert your numbers to 64-bit fixed-point integers:

const fixedNum = BigInt(num * 2 ** 64);
int fixedNum = num << 64;

Here are all functions exposed by the library:

import {
  exp2,
  exp,
  mostSignificantBit,
  log2,
  log,
  log10,
  sqrt,
  root,
  pow,
} from "bsv-fixmath";

const fixedResult = exp(fixedNum);
const result = Number(fixedResult) / 2 ** 64;
import "./fixMath.scrypt";

int fixedResult = FixMath.exp(fixedNum);
int result = fixedResult >> 64;
You might also like...

"Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to make simple calculations and read random math-related quotes. Its built using react

Math Magician "Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to make simple calculations a

Feb 23, 2022

Module 03 project: Math magicians is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to Make simple calculations and Read a random math-related quote.

Math-magicians Math magicians is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to Make simple calculations an

Sep 26, 2022

Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations and Read a random math-related quote.

Capstone project / FilmTube This is the final project of the moduel 2. we build a series page using an API to display all the series on the main page

Aug 23, 2022

"Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations. Read a random math-related quote.

ONLINE MATH CALCULATOR USING REACT "Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make

Aug 24, 2022

"Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to make simple calculations and read a random math-related quote.

Math magicians "Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations

Aug 26, 2022

A fixed-width file format toolset with streaming support and flexible options.

fixed-width A fixed-width file format toolset with streaming support and flexible options. Features Flexible: lot of options Zero dependencies: small

Jul 14, 2022

Framework for interacting with instagrams private api in a usable manner (forked from andre's work and improved and fixed)

node-ig-framework Framework for interacting with instagrams private api in a usable manner (forked from andre's work and improved and fixed) Installat

Dec 31, 2022

Simple fixed background parallax effect in vanilla js.

Simple Parallax Simple fixed background parallax effect in vanilla js. See demo on Codepen. JS Initialise the plugin. The first argument identifies th

Jun 27, 2022

Javascript library for switching fixed elements on scroll through sections. Like Midnight.js, but without jQuery

Library for Switching Fixed Elements on Scroll Sometimes designers create complex logic and fix parts of the interface. Also they colour page sections

Sep 19, 2022
Bitcoin terminal tracker is a terminal app which allow you to track bitcoin price from your terminal

BTC Terminal Tracker Bitcoin terminal tracker is a terminal app which allow you to track bitcoin price from your terminal. In this version (V1.2) I ch

Sina yeganeh 9 Jul 27, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
"Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations. Read a random math-related quote.

math-magicians A Single Page App (SPA) that allows users to Make simple calculations and read a random math-related quote. "Math magicians" is a websi

Temitope Ogunleye 3 Feb 21, 2022
Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations. Read a random math-related quote.

Math Magicians. Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations

Mithlesh kumar 5 Mar 29, 2022
Math magicians is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to make simple calculations and read a random math-related quote. Build with React.js

Math Magicians Math magicians is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to make simple calculations an

Kyrillos Hany 9 Mar 23, 2022
It is a simple Math Sprint Game in which the user must agree or disagree with the answers to math problems in the quickest time possible.

MATH-SPRINT-GAME The user must agree or disagree with the results of math equations in this Math Sprint Game. The amount of time the player spends mak

AMEY THAKUR 8 Aug 1, 2022
"Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations. Read a random math-related quote.

Math Magician "Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations.

Emmanuel Allan 6 Jun 27, 2022
Math magicians is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations. Read a random math-related quote.

react-math-magicians React Math magicians is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: - - Make simpl

null 5 May 27, 2022