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 is given.I must get y1-y4 from it.
How can I do this on my 32bit PC?
Sorry for that my English is poor.
Thanks.
Mar 3 '06
42 3377
On 6 Mar 2006 19:50:19 GMT, in comp.lang.c , Jordan Abel
<ra*******@gmai l.com> wrote: Post code that you think safely uses gets and i'll prove it wrong within the context of the API you are using to "ensure" it.
This is such an easy challenge to defeat, I won't embarrass you.
[well, i'm hoping you're using the unix api, since i wouldn't have the first clue about any other one]
Quite.
Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
On Mon, 06 Mar 2006 12:34:53 -0800, in comp.lang.c , Ben Pfaff
<bl*@cs.stanfor d.edu> wrote: ro******@ibd.n rc-cnrc.gc.ca (Walter Roberson) writes:
In article <sl************ ***********@ran dom.yi.org>, Jordan Abel <ra*******@gmai l.com> wrote:Post code that you think safely uses gets and i'll prove it wrong within the context of the API you are using to "ensure" it. [well, i'm hoping you're using the unix api, since i wouldn't have the first clue about any other one]
How about something like this:
Open a file w+. Write known data into it. fseek() back to the beginning of the file. gets() with a buffer at least as big as the data to be written.
gets() reads from stdin. You'll have to use freopen() to replace stdin by your file. Seems like a pretty big stretch to make just to use gets() safely, when you could just use a better designed function instead.
Nobody's arguing that its sensible to use gets(), merely with the
assertion that its "impossible " to use safely, even in a controlled
envrionment.
Heck if nuclear waste and anthrax can be safe, in the right
environment then ...
Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
russell kym horsell wrote: yong <yo************ ****@gmail.com> wrote:
Hi all I have an large integer in this format
[lemm call this X:]
x1*256^5 + x2*256^4 + x3*256^3 + x4*256^2 + x5*256 + x6 now I must convert it to this format
[Y:]
y1*900^4 + y2*900^3 + y3*900^2 + y4*900 + y5 x1-x5 is given.I must get y1-y4 from it. How can I do this on my 32bit PC? Sorry for that my English is poor. Thanks. Some kind of pdf encoder, eh?
There's probably a lot of literature on smart tricks, but the basic idea (beside simply using 64-bit integers and brute force -- BTW even 32-bit PC's can do h/w 64-bit arith these days) is to note that
X % 900 = Y % 900 = y4.
Then we see that 256^5 % 900 = 376 256^4 % 900 = 796 256^3 % 900 = 316 256^2 % 900 = 736 256^1 % 900 = 256
So we must have y4 = (376*x1 + 796*x2 + 316*x3 + 736*x4 + 256*x5 + x6) % 900 . (Look, maw, only 16-bit arithmetic!)
Similiarly for the other y_i.
Thanks.
It's really a good idea. :]
--
My Personal Weblog: http://spaces.msn.com/cyberisblue This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Együd Csaba |
last post by:
Hi All,
how can I improve the query performance in the following situation:
I have a big (4.5+ million rows) table. One query takes approx. 9 sec to
finish resulting ~10000 rows. But if I run simultaneously 4 similar queries
it takes nearly 5 minutes instead of 4 times 9 seconds or something near of
that.
here is a sample query:
select mertido, fomeazon, ertektipus, mertertek from t_me30 where fomeazon
in (select distinct fomeazon...
|
by: Zero |
last post by:
Hi,
I am calculating an integer to the pwer of a large integer, e.g.
2^5000.
It turns out that the result I always get is zero. I am sure that the
result is too large to store in such type as u_int64_t and long int
etc.
My power function is as follows: for(i=0; i<5000; i++) result *= 2;
|
by: platinumbay |
last post by:
I am trying to load large flat files; > 250 MB. What is the best practice
for this? I have already read through everything I could find on Google, to
no avail.
I have a SQL DTS process that will load the file in about 7 minutes. My
code takes about an hour.
Here is a snippet:
Dim objSR As StreamReader = System.IO.File.OpenText(objOrigFile)
|
by: sebastian.harko |
last post by:
Helllo,
What's the general accepted strategy for dealing with very large
binary files in C# ?
I have to do a program that reads some "multi frame bitmap " files
which can reach up to one hundred megs so I need to know how to
optimize reading a file..
Best regards,
Seb
|
by: Jonathan Wilson |
last post by:
I am working on some software which has to deal with data that could be as
large as 500mb or so. Currently I am using new and delete to manage
this memory but I find it is not ideal and sometimes gives out of memory
errors if I open one large data item then free that data item then another
large data item even though I have enough memory (including 2GB of physical
RAM and 100GB of free disk space for swap file). Are there any functions...
| |
by: kerravon |
last post by:
The following C program:
int main(void)
{
int x = -2147483648;
return (0);
}
Produces the following warning:
|
by: zephyrus360 |
last post by:
This is about a technique to find the mod of a very large integer with a normal small integer.
I recently encountered this problem when I needed to compute the modulus of a very large number with a normal integer. I needed this in a C++ program running on a 32-bit UNIX platform. The problem was that the number was 28 digits long and no native datatype in c++ could store a number of that size.
(Eg: 1088263455689473669888943602 % 380)
Not...
|
by: Shisou |
last post by:
hello everyone,
Well I tried to solve this one on my own but it seems i need your help again :\
I'm trying to write a program to add or subtract two large integers... easy enough..
Where i run into problems is working with pointers. Here's where i'm at right now.
I have a function that takes in the integers as strings and puts it into a struct
|
by: pereges |
last post by:
ok so i have written a program in C where I am dealing with huge
data(millions and lots of iterations involved) and for some reason the
screen tends to freeze and I get no output every time I execute it.
However, I have tried to reduce the amount of data and the program
runs fine.
What could possibly be done to resolve this ?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |