ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
ok i want to read 200kb of raw data.....
and put it in to memory as a real number
and i want access to that number so ican do calculations on it
like half it find the power and that lot
Not going to happen without a special library to perform calculations with numbers of that magnitude, and even then, it will take a LONG time to perform mathematical calculations with numbers like that.
i just want to read 200kb of data (hexed) and put it in to decimal...which would result ina file that is 300kb
now i want to read that 300kb in to memory and access it as a number..so i can perform division on it
so i can find the power i need to get close to that file
200kb of hex? That would be 100kb of raw (binary) data. Why do you need to find that power?
You'll need to write a program that uses the GNU Multiple Precision library, or something similar, to perform this math. If you intend to use it as an integer, you can use mpz_set_str(mpz_t val,char *string) with the value prepended with 0x and terminated in a null. You can use getc() to create this string in memory.
ok i dont care about programming
i just want to know the lines of code to read raw data one byte a time..convert to dec and write the resulting code in to memory
and that give em a solution so i can access that number via a varible
so if i did newval = val / 2 (i know that not probably right) but that would give me a val in newval which is half the size....which that all i would have to do is this newval x 2 = val
so thats it....i dont actually get any help aprt from some code that i dont know what it is for..i assume it is either C or C++
but dunno if the idea of just halving value will result in it being smaller in generally no mater what it is
What kind of help do you want? I pointed you to the proper libraries and functions, and gave you sample code to read in the value. With that value, you'll have to use the GNU MP library's functions to manipulate it.
just say u could make a number turn in to a base that supported 300k....i could represent any 300kb number with very few numbers yes......ok i want to know if i could just tell u any number in sequence.....and u could work it out...e.g. 3000 digit ..now u tell me what info u need to determine a number by cubing ..
1. you dont ask what programming language you need help in so we assumed it was C because of its ablity to manipulate memory easly.
the code written here is C if im mistaken somone correct me please. Thats a nice bit of code and does answer your question. It however is not compleate (not my words but the words of the author) and should not be used in its pure form but compleated with proper error checking.
now even if 300kb of raw data doesent seam like alot as far as modern space on computers go it acutally is a huge amount of data when working with raw binary data in programming.
please rewrite your question with some details on what you are trying to accomplish and we will be happy to assist you in any way.
Im not trying to be mean or anything but your question is kinda just thrown out there so you get erratic results.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.