Calculating with very big values  Linux
This is a discussion on Calculating with very big values  Linux ; Hi I've got a "little" problem. A program have to calculate big values. See
the following onelinecode:
size_pair::size_type diskFree = size_pair::size_type( get_disk_size_mb() ) *
MEGABYTE(1)  get_tracks_size(cut_, track_info::streamtype_audio) * 1.06;
The result of 'get_tracks_size(cut_, track_info::streamtype_audio) * 1.06'
is in my ...

Calculating with very big values
Hi I've got a "little" problem. A program have to calculate big values. See
the following onelinecode:
size_pair::size_type diskFree = size_pair::size_type( get_disk_size_mb() ) *
MEGABYTE(1)  get_tracks_size(cut_, track_info::streamtype_audio) * 1.06;
The result of 'get_tracks_size(cut_, track_info::streamtype_audio) * 1.06'
is in my testing case: 8.985683e+08
This seems to be ok.
The result of 'size_pair::size_type( get_disk_size_mb() ) * MEGABYTE(1)' is
in my case: 723517440
This is wrong!
get_disk_size_mb() = 23500
MEGABYTE(1) = 1024^2 = 1024*1024
So the expected value is about: 24641536000 (<this is the max expected
value)
I AFAIK size_pair::size_type is long long unsigned int (not sure about
that). So what should I do, in order to get bigger correct result?
A important thing: The first part 'get_tracks_size(cut_,
track_info::streamtype_audio) * 1.06' may be big as 24641536000 or even
bigger (maybe ~ 4000000000050000000000).
cu Floh
PS: It runs on 32BitMachine (Kubuntui386).

Re: Calculating with very big values
Florian Erfurth writes:
> Hi I've got a "little" problem.
Actually, you've got a big problem: you appear not to understand
how numbers are represented in the computer, and what it means to
operate on 32bit integers.
> So the expected value is about: 24641536000 (<this is the max expected
> value)
That value can't be represented in a 32bit integer (you need at
least 35 bits to represent it).
> I AFAIK size_pair::size_type is long long unsigned int
Since you didn't tell us what 'size_pair' is, we can't tell you what
'size_pair::size_type' is either. However, assuming 'size_pair'
is a typedef for some kind of 'std:air<...>' the 'size_type' is the
same as std::size_t, which is unsigned int, which is a 32bit number.
> So what should I do, in order to get bigger correct result?
Use numbers of a type that *can* represent your correct result
(that would be 'long long' or 'unsigned long long').
Cheers,

In order to understand recursion you must first understand recursion.
Remove /nsp/ for email.

Re: Calculating with very big values
Paul Pluzhnikov wrote:
> Florian Erfurth writes:
>
>> Hi I've got a "little" problem.
>
> Actually, you've got a big problem:
What do you think why I did write "little" in quotes?
>> So the expected value is about: 24641536000 (<this is the max expected
>> value)
>
> That value can't be represented in a 32bit integer (you need at
> least 35 bits to represent it).
As I thought so.
>> I AFAIK size_pair::size_type is long long unsigned int
>
> Since you didn't tell us what 'size_pair' is, we can't tell you what
> 'size_pair::size_type' is either. However, assuming 'size_pair'
> is a typedef for some kind of 'std:air<...>' the 'size_type' is the
> same as std::size_t, which is unsigned int, which is a 32bit number.
I didn't wrote the code by myself so I can't tell you extactly about that.
I'm sorry.
>> So what should I do, in order to get bigger correct result?
>
> Use numbers of a type that *can* represent your correct result
> (that would be 'long long' or 'unsigned long long').
Hm... may you explain me what is the difference between 'unsigned long long'
and 'long long unsigned int', please?
Thank you very much!
cu Floh

Re: Calculating with very big values
Florian Erfurth writes:
>> Since you didn't tell us what 'size_pair' is, we can't tell you what
....
> I didn't wrote the code by myself so I can't tell you extactly about that.
> I'm sorry.
Does the fact that you didn't write the code prevent you from
*reading* it? If so, you've got an even bigger problem.
> Hm... may you explain me what is the difference between 'unsigned long long'
> and 'long long unsigned int', please?
There isn't. But you are likely no using either.
Cheers,

In order to understand recursion you must first understand recursion.
Remove /nsp/ for email.