473,320 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Autoscale large integer calculations to avoid overflow

15 Byte
I have some code that will (frequently) generate S sets of C count of relatively large integers N.
I need the set with the lowest product.

int S ranges 7 .. 15 (run-time constant defined at startup).
int C ranges 2 .. 13 (defined by caller for each call).
int N ranges 0 .. 2000 (values cannot be predicted by caller).
…any N==0 in a set aborts the generation of that set (S—)
…if all sets contain N==0, prog (tries to) generate S new sets for the same C
…if candidates exhausted, prog branches elsewhere.

I considered iteratively-decreasing bit-shifts, discarding high-product sets at each step, but this is likely to be slow. My programme will repeat this set-selection process many thousands of times: slow is not a happy option.

Is there a clever (fast) way to "autoscale" this product calculation so I get the best precision possible without overflow?

Chris (MacM1, Clang, C)
Mar 12 '23 #1
0 1049

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: deancoo | last post by:
When you increase the number contained within an integer or long data type beyond its capacity, what happens? I've run into this situation, and it continues right along. Is it simply just rolling...
20
by: Russell Shaw | last post by:
Hi, I'm using gcc-3.4.3 on a linux pc. The ints and long ints are 32 bits and long long ints are 64 bits. When i have: int num=9600; long long int reg=(long long)800000000000/(5000000*num);...
42
by: yong | last post by:
Hi all I have an large integer in this format x1*256^5 + x2*256^4 + x3*256^3 + x4*256^2 + x5*256 + x6 now I must convert it to this format y1*900^4 + y2*900^3 + y3*900^2 + y4*900 + y5 x1-x5...
8
by: Alex Fraser | last post by:
Can negating a non-negative signed integer value ever overflow? Put another way, can it be true that (mathematically) INT_MIN > -INT_MAX, LONG_MIN > -LONG_MAX etc? I know that typically it can't...
8
by: Steven D'Aprano | last post by:
I thought that overflow errors would be a thing of the past now that Python automatically converts ints to longs as needed. Unfortunately, that is not the case. .... pass .... 2147483647...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.