what is data transmission rate in bits per second ? - networking

suppose that data are stored on 4.7 Mbytes CDs that weight 50 grams each.suppose that an airplane carries 10^4 kg of these CDs at a speed of 1500 km/h over a distance of 5000 km.what is data transmission rate in bits per second of this system?

I would not call this 'data-transmission', but:
Amount of CD's = 10^4 / 0.05 = 2e5
Amount of bits = 4.7e6 * 8 * amount of CD's = 7.52e12
Seconds to carry data = 5000e3 / (1500/3.6) = 12000 seconds
(7.52 * 10^12)/ 12000) = 0.6Gbits/s

Related

Discount rates, Formulas

for example, I have 1 computer with a discount, the price of this computer is $ 450 with a 10% discount, I want to know the real price of it,
I want to learn this both over 10% and as 10% money.
Computer 10% off Price = 450$
Computer $10 off Price = 490$
$net_total = 450;
$discount_value = 10; < percent or amount
$gross_price = ?;
Well, let's solve the equations:
Computer 10% off Price = 450$
Computer $10 off Price = 490$
Which can be written as (let x be the initial price of the computer)
x - x * 10 / 100 = 450 # initial price - x without 10 % from x - x * 10% / 100%
x - 10 = 490 # just 10$ off
Or
0.9 * x = 450
x = 500
Finally
x = 450 / 0.9 = 500
x = 500
So from both equations we have that the initial computer's price is 500$
Edit: in general case,
if $discount_value stands for per cent (i.e. $discount_value = 10 means 10% discount) then
$gross_price = $net_total * 100.0 / (100.0 - $discount_value)
if $discount_value stands for money (i.e. $discount_value = 10 means 10$ discount), then
$gross_price = $net_total + $discount_value

How to convert 10^4 to binary

I need to convert 10^4 to binary
expanding it will give me a large number and dividing that by 2 a bunch of times will be really inefficient
10^4 = 10000
how do i do it directly
I would write a recursive function, the pseudo-code is here:
int Convert_to_binary (x):
if(x == 0):
return 1;
if(x == 1):
return 10;
if(x%2 == 1):
return Convert_to_binary(x-1)+1;
if(x%2 == 0):
return Convert_to_binary(x/2)*10;
This will return the binary format as an integer like 2 is 10 in binary and 1 is 1
in binary format and 3 is 11 and so on
There is a quick method to convert decimal number to binary form,
0^2 = 1
1^2 = 2
2^2 = 4
2^3 = 12
2^4 = 16
2^5 = 32
2^6 = 64
2^7 = 128
2^8 = 256
2^9 = 512
2^10 = 1024
2^11 = 2048
2^12 = 4096
2^13 = 8192
2^14 = 16384
Since we want to find binary of 10000, we can stop at 2^13. The number 13 means that the binary of 10000 is 14 bit long(0-13).
1000 - 8192 = 1808
so we next want to find the number's that sum up to 1808 from the 2^0 to 2^10 (2^10<1808). it's not difficult to find whch are those numbers from the table
2^10 = 1024
2^9 = 512
2^8 = 256
2^4 = 16
1024+512+256+16 = 1808
That means in the binary form of the decimal number 10000 only the 13, 10, 9, 8, 4 bit position's are '1' other bit position's are '0'.
so the binary of 10000 is,
```
10011100010000
```
It's easy to remember the above table so we don't need to use the very basic
tedious method to convert a decimal number to binary form.

Reverse percentage to get actual amount

I ran into scenario where my client wants to know the original amount after percentage deduction. They are collecting online donation where user enter its amount and then percentage values (bank charges and FED) are added in his amount to ensure that my client always get exact amount in his account after percentage deduction.
For example:
Donation amount = 32,000
Bank charges = 3%
FED charges = 13%
Calculation:
Deducting bank charges = 32000 * .03 = 960
Deducting FED on bank charges = 960 * .13 = 124.80
Total = 32000 + 960 + 124.80 = 33,084.80
I now want to reverse the amount 33,084.80 to get the exact actual amount of 32,000.
Let Bank charges = b, FED charges = f (here b=0.03, f=0.13)
Then
Donation + Donation * b + Donation * b * f = Total
Donation * (1 + b + b * f) = Total
so
Donation = Total / (1 + b + b * f)
here
Donation = 33,084.80 / (1 + 0.03 + 0.03 * 0.13) = 33,084.80 / 1.0339 = 32,000

Maths help on function to return number of items in container

This should be simple enough but the maths for this eludes me. I am looking to express this in C++ but some psuedo code will happily do, or just the maths really.
The function will be given a number of a container and it will return the number of items in that container. The number of items is based on their number and halves at certain number height.
The first halving is at number 43,200 and then every time after it is the gap number of containers between the previous halving plus 43,200
It may sounds confusing, it will look like the following.
1 to 43200 = 512
43201 to 86400 = 256
86401 to 129600 = 128
129601 to 172800 = 64
172801 to 216000 = 32
216001 to 259200 = 16
and so
So if a number up to 43,200 is given the result is 512, the number 130,000 will return 64. The value can be less than 1 taking up several decimal places.
global halvingInterval = 43200
global startingInventory = 512
def boxInventory(boxNumber):
currentInventory = startingInventory
while(boxNumber > halvingInterval):
currentInventory = currentInventory/2
boxNumber -= halvingInterval
return currentInventory
This code will take the box number. It will keep subtracting the halving interval until you get to the right inventory area, and then return the inventory when it is done.
N = (noitems + 1) / 43200;
L2 = log(512) / log(2);
answer = exp( log(2) * (1 + L2 - N) );

Split down a number in seconds to days, hours, minutes, and seconds?

I've heard that it's possible to accomplish this using the modulus % operator present in most programming languages. The real question is, how? I'm unfamiliar with how modulus works, so I've had difficulties using it in the past. Given the present time here in seconds since 1970, 1307758473.484, how can I calculate how many years that is, days that is, hours that is, and minutes that is using modulus?
I'm essentially looking to format it like this: "5 years, 10 days, 12 hours, 7 minutes, and 18.56 seconds". How would I do this? I'm really interested in learning the logic behind this and not interested in a simple drop-in solution.
When you do integer division, you get quotient and remainder. For example,
5 divided by 3 is quotient 1 with remainder 2.
In programming languages, this is usually expressed as:
5 / 3 # => 1
5 % 3 # => 2
The conversion you want is just a repeatation of this. It's easier to to start from the lower unit and go higher on.
First, you have
1307758473.484 seconds
Since 60 seconds is 1 minute, and
1307758473.484 / 60 = 21795974 (intended to be integer division)
1307758473.484 % 60 = 33.484,
it is the same as
21795974 minutes 33.484 seconds
Since 60 minutes is 1 hour, and
21795974 / 60 = 363266
21795974 % 60 = 14
it is further the same as
363266 hours 14 minutes 33.484 seconds
Now, there is a little bit of difficulty. Most days are 24 hours. When there is a leap second, it is not. If you ignore leap seconds and assume 1 day is 24 hours, then, by doing the calculation,
363266 / 24 = 15136
363266 % 24 = 2
it is further the same as
15136 days 2 hours 14 minutes 33.484 seconds.
Similarly, Most years are 365 days. When there is a leap day (year), it is not. If you ignore leap days and assume that 1 year is 365 days, then by doing the calculation,
15136 / 365 = 41
15136 % 365 = 171
it is further the same as
41 years 171 days 2 hours 14 minutes 33.483 seconds
Modulus returns the remainder when performing integer division.
I think its easiest to understand how to use Mod by working backwards through a problem first.
Lets start simple with hours, minutes and seconds - 1 hour, 10 minutes and 30 seconds to be precise.
First, you have 30 seconds. This is easy - it's just 30. No brainer.
Now add minutes - to determine minutes as seconds you multiply them times 60. Thus 10 minutes and 30 seconds = 630 seconds.
Now we see how mod works - because if you divide 630 by 60 you get 10.5 but if you ignore the fraction (whole integer division) you get 10. The remainder is the seconds.
So if you MOD 630 by 60 you get 30 - the remainder left over when dividing 630 by 30.
So to determine minutes and seconds, divide by 60 for the minutes, and mod by 60 for the seconds.
Now add an hour. One hour = 60 minutes and 60 minutes is 60*60 seconds so 1 hour = 3600 seconds. 3600 + 600 + 30 = 4230 seconds.
4230 / 3600 (1 hour) = 1 - so we have one hour
4230 % (mod) 3600 = 630 - grab this and now we process for minutes.
So if you flesh this out further and add a day - 1 day = 24 hours = 24*3600 = 86400
86400+3600+600+30 = 90630
90630 / 86400 = 1 -> 1 day
90630 % 86400 = 4230 -> seconds left over
4230 / 3600 = 1 -> 1 hour
and repeat the above logic.
Hope that helps clear it up - you keep repeating that iteration further and you can do weeks and years, but months are special since they're irregular, and so are leap years.
Whenever converting from a small base unit (seconds) to a series of larger units (minutes/hours/days/years/decades/centuries/millennia) you can use the modulo (%) operator to keep track of the remaining base units as you extract each large unit.
It is an elegant/simple way to keep a sort of running total in base units. Start extracting BaseUnits with the largest unit you want and work your way back down until you get to the original BaseUnit.
This only works when the extracted unit is nonzero. If it's zero then you have extracted no base units at all and don't need the modulo operator.
It is important to remember that the result of the modulo operation will always be in the original base unit. That can get confusing.
Let's restate 1 million seconds as larger time units. Let 1 year = 31,536,000 seconds and no leap years or other calendar adjustments.
#include <cstdio>
#define SEC2CENT 3153600000
#define SEC2DEC 315360000
#define SEC2YR 31536000
#define SEC2MONTH 2592000
#define SEC2WEEK 604800
#define SEC2DAY 86400
#define SEC2HOUR 3600
#define SEC2MIN 60
main()
{
unsigned int sec = 1000000; //I am 1 million seconds old or...
unsigned int centuries = sec / SEC2CENT;
if (centuries) sec = sec % SEC2CENT; //if nonzero update sec
unsigned int decades = sec / SEC2DEC;
if (decades) sec = sec % SEC2DEC; //the purpose of modulo for units is this running total of base units
unsigned int years = sec / SEC2YR;
if (years) sec = sec % SEC2YR;
unsigned int months = sec / SEC2MONTH;
if (months) sec = sec % SEC2MONTH;
unsigned int weeks = sec / SEC2WEEK;
if (weeks) sec = sec % SEC2WEEK;
unsigned int days = sec / SEC2DAY;
if (days) sec = sec % SEC2DAY;
unsigned int hours = sec / SEC2HOUR;
if (hours) sec = sec % SEC2HOUR;
unsigned int minutes = sec / SEC2MIN;
if (minutes) sec = sec % SEC2MIN;
unsigned int seconds = sec; //seconds should now be less than 60 because of minutes
printf("I am now exactly %u centuries, %u decades, %u years, %u months, %u weeks, %u days, %u hours, %u minutes, %u seconds old and that is very old indeed.", centuries, decades, years, months, weeks, days, hours, minutes, seconds);
}

Resources