arbitrary-precision

Outputting values from CAMPARY

被刻印的时光 ゝ 提交于 2021-02-08 10:22:06
问题 I'm trying to use the CAMPARY library (CudA Multiple Precision ARithmetic librarY). I've downloaded the code and included it in my project. Since it supports both cpu and gpu, I'm starting with cpu to understand how it works and make sure it does what I need. But the intent is to use this with CUDA. I'm able to instantiate an instance and assign a value, but I can't figure out how to get things back out. Consider: #include <time.h> #include "c:\\vss\\CAMPARY\\Doubles\\src_cpu\\multi_prec.h"

How to divide large numbers with a floating point?

ⅰ亾dé卋堺 提交于 2021-01-28 04:53:06
问题 I have some large numbers (like 10000000 digits in total or more ). Since I will lose precision, they are stored like strings . Lets take some 'small' numbers as an example (some numbers also can be integers): a = 4782916578987656789087654678908765467417657489104.9486718490129876578 b = 657890876566567890.8765467890987654 I want to make some operations on them. Division . Well, answer is 7.270075858095143e+30 Multiplicaiton: 3.1466371806949598e+66 And so on. Desirable output is full number as

PHP gives incorrect results when formatting long numbers

半世苍凉 提交于 2020-06-27 06:49:25
问题 I am working with huge numbers for website purposes and I need long calculation. When I echo a long number I don't get the correct output. Example // A random number $x = 100000000000000000000000000; $x = number_format($x); echo "The number is: $x <br>"; // Result: 100,000,000,000,000,004,764,729,344 // I'm not getting the value assigned to $x 回答1: Your number is actually too big for php standard integers. php uses 64 bit integers which can hold values within range -9223372036854775808 ( PHP

C# unlimited significant decimal digits (arbitrary precision) without java [duplicate]

霸气de小男生 提交于 2020-01-27 08:46:16
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: what is the equivalent for java class : BigDecimal in c# I know in this post: Arbitrary precision decimals in C#? says to use java.math.BigDecimal, but I don't have J# installed. How would I achieve arbitrary precision in C#? I was thinking of using binary strings but I may run into some trouble when multiplying the two. 回答1: See What is the equivalent of the Java BigDecimal class in C#? You could create your

C# unlimited significant decimal digits (arbitrary precision) without java [duplicate]

≡放荡痞女 提交于 2020-01-27 08:42:10
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: what is the equivalent for java class : BigDecimal in c# I know in this post: Arbitrary precision decimals in C#? says to use java.math.BigDecimal, but I don't have J# installed. How would I achieve arbitrary precision in C#? I was thinking of using binary strings but I may run into some trouble when multiplying the two. 回答1: See What is the equivalent of the Java BigDecimal class in C#? You could create your

JavaScript pack integers and calculate arbitrary precision float:

时光毁灭记忆、已成空白 提交于 2020-01-11 06:48:10
问题 I need to do the following in JavaScript and so far been unable to find solutions to do it seamlessly: Grab two integers in a specific order and pack them like Python's struct module. This packed value, (bonus for supporting different endianness than host) will be turned into a 64 bit float (double). They must be arbitrary thus I might get an exponent representation of the integer (say, they could be 0xdeadbeef and 500): In exp form: 1.0883076389305e-311 1.0883076389305000 * 10 ^ - 311 I need

manually printing a N-byte integer

自古美人都是妖i 提交于 2020-01-03 11:47:11
问题 What is a scalable algorithm to print an N-binary-digit integer manually whose value does not fit in long long . I know printf and friends, along with <iostream> (which most likely piggy-backs on <cstdio> have this builtin for standard types, but I'd like to do it for an integer composed of N bytes. I have thought about this and googled a bit, but it always comes down to using a pre-existing bigint libirary like GMP (a codebase I am not at all familiar with) or "use printf" or the most

manually printing a N-byte integer

吃可爱长大的小学妹 提交于 2020-01-03 11:47:10
问题 What is a scalable algorithm to print an N-binary-digit integer manually whose value does not fit in long long . I know printf and friends, along with <iostream> (which most likely piggy-backs on <cstdio> have this builtin for standard types, but I'd like to do it for an integer composed of N bytes. I have thought about this and googled a bit, but it always comes down to using a pre-existing bigint libirary like GMP (a codebase I am not at all familiar with) or "use printf" or the most

Number type boundaries in Common LISP and Stack flowing over in GHCI

北慕城南 提交于 2020-01-03 10:55:28
问题 First question ever here, and newbie in both Common LISP and Haskell, please be kind. I have a function in Common LISP - code below - which is intended to tell whether the area of a triangle is an integral number (integer?). (defun area-int-p (a b c) (let* ((s (/ (+ a b c) 2)) (area (sqrt (* s (- s a) (- s b) (- s c))))) (if (equal (ceiling area) (floor area)) t nil))) This is supposed to use Heron's formula to calculate the area of the triangle, given the size of the three sides, and decide