Jump to content

John Cuthber

Resident Experts
  • Content Count

    16960
  • Joined

  • Last visited

  • Days Won

    26

Posts posted by John Cuthber


  1. 6 hours ago, Sensei said:

    The simplest brute-force dividing algorithm in C/C++ would look like:

    
    int quotient = 0;
    while( dividend >= divisor ) {
       dividend -= divisor;
       quotient++;
    }
    int reminder = dividend; // subtraction failed
    

    "subtract divisor from dividend until dividend is greater than or equal to divisor".

    The number of repetitions on the loop will be O(quotient)

     

    The more sophisticated version could left-shift divisor prior subtraction from dividend. Each binary left-shift operation is multiplication by 2. At the same time value added to quotient should be multiplied by 2. (In binary numeral system left-shift is equivalent of multiplication by 2, move the all bits one position to the left and make room for 0 at the end for the least significant bit)

    So e.g. division of 1000 by 50 will look like:

    temporary_quotient = 1;

    1000 > 50 (true)

    50*2 = 100, temporary_quotient*2 =2

    1000 > 100 (true)

    100*2=200, temporary_quotient*2=4

    1000>200 (true)

    200*2=400, temporary_quotient*2 =8

    1000>400 (true)

    400*2=800, temporary_quotient*2=16

    1000>800 (true)

    800*2=1600, temporary_quotient*2=32

    1000>1600 (false! We are using previous values and subtract it from 1000! i.e. 800 and 16)

    1000-800=200, quotient += temporary_quotient (16)

     

    Repetition of entire procedure once again:

    temporary_quotient = 1;

    200 > 50 (true)

    50*2 = 100, temporary_quotient*2=2

    200 > 100 (true)

    100*2=200, temporary_quotient*2=4

    200 == 200 (they are equal, end of the loop)

    200-200=0, quotient += temporary_quotient (16+4=20)

     

    50 * 20 = 1000

     

    That reminds me that the single division operation in machine code of Motorola 68000 (Amiga 500, Atari ST) was talking over 150-170 cycles of cpu (running at 7.16 MHz) (unsigned integer div faster, signed integer div slower). So at max it could do just 7,160,000 / 150 = ~47,000 divisions per second.

     

    I know it's just an illustration of the point but, it's worth mentioning that you should check that you are not trying to divide by zero, or you get stuck in an infinite loop.


  2. On 1/4/2020 at 5:01 PM, Rachel Maddiee said:

    If the group ends in the suffix -ite(with less less oxygen atoms bonded), it changes to -ious

    No, it changes to "-ous".

    Sulphurous, nitrous etc don't have an "i".


  3. 1.  Yes, you can precipitate the silver in the excess solution as silver chloride by adding dilute hydrochloric acid (The acidity also prevents the explosion hazard associated with the ammonia/ silver complex).

    You can then heat the silver chloride with sodium carbonate  or treat it with zinc and acid to convert it to sliver metal, then redissolve the metallic silver in nitric acid.

    2. Just about. You can make copper (and platinum- but it isn't cheap)  mirrors this way but most metals are too reactive. They can't be produced in water because they react with water.

     

    3. Well, it's one of the commercial processes for making mirrors.
    The usual alternative is deposition of metal- typically aluminium- in a vacuum chamber.
    The set up costis higher, because you need a big vacuum chamber, but the running cost is low because you can use aluminum , and you don't have chemical waste problems.

    If you want to silver the inside of small glass objects then the chemical method is better.

    It used to be the standard way of making xmas decoration baubles.


  4. I realise it's probably impractical but, by far, the best way to reduce the contamination is to get the smokers to go outside.

    No matter how good the purifier is, there will be particles "en route" to it which you will be stuck with inhaling.

    To some degree, it's not a matter of how good the filter is, but how fast the fans can push air through that filter.

    For example, if the fans only move 10 m3 per hour but  the room's natural ventilation is 100 m3 per hour, the filter isn't going to achieve as much as you would hope.

    https://en.wikipedia.org/wiki/Air_changes_per_hour


  5. On 1/3/2020 at 1:39 AM, Erina said:

    I think that the surrounding solution is a mix of water an ethanol as it conducts to the heat better than just water.

    I doubt that.

    Water is one of the best conductors.

    https://www.engineeringtoolbox.com/thermal-conductivity-liquids-d_1260.html

    However, the driving force of these thermometers is the expansion of the liquid.

    Ethanol expands much more than water does. (which makes it easier to get the thermometer to work.)

    In particular, near 4C the expansion of water is zero.

    It seems to me that it would be easier to use (more or less) pure alcohol. That way you don't need to carefully mix the right concentration every time you make a batch of thermometers..

    In principle, you can use Raman spectroscopy to find out what's in the tube without opening it.


  6. On 12/28/2019 at 3:14 AM, ChildOfMaroon said:

    I am trying to figure out which chemicals/compounds might cause mild chemical burns in liquid form.

    Why?

    I can't think of any good reason for this.
     

    On 12/28/2019 at 4:05 AM, Sensei said:

    It is acid and OP said: "I am not necessarily interested in things which would cause severe burns like acid".

     

    And vinegar doesn't "cause severe burns like acid" so...


  7. 17 hours ago, MigL said:

    Sooo...

    Creationism vs. Evolution defines your political ideology ?
    I always thought that defined ignorance ( and possibly a little stupidity )

    No, the point raised consistently throughout that thread is that, while barking mad Republicans are ten a a penny, it seems relatively difficult to find their Democrat counterpart.

    You might remember this exchange of posts in that thread

    "Are you saying that this guy is not the best the republicans can come up with for this election?"
    "Well, the Dems have Biden, don't they?"
    "Ok, what has Biden said that was completely batshit crazy?"
    "Nothing as far as I know. I"

    I asked, repeatedly, in that thread for any evidence of any mainstream Lefty saying anything as profoundly dumb as the bloke who believes in dragons.
    That was in 2012.

    I am still waiting.

    So, I have a hypothesis.

    Only the political Right vote for people who are obviously clueless.


  8. 5 hours ago, Prometheus said:

    How?

    I never came across that in 6 years of A&E nursing. There's a difference in the presentation of abdominal and associated pains, but for the ones you have listed i can't remember any instances where knowing the sex made any difference to the patient's outcome. 

    I'm  fifty-something man and , if I turn up in A&E with chest pains I expect to jump the queue in a way that my hypothetical twin sister wouldn't.

    I'm not saying that's good or right; I'm saying it's what happens.


  9. Did anyone actually read the judgement- or even the newspaper highlights of it?
     

    ""It is a core component of her belief that she will refer to a person by the sex she considered appropriate even if it violates their dignity and/or creates an intimidating, hostile, degrading, humiliating or offensive environment," he continued."

    Now that's not a decent way to behave.
    And Rowling was factually wrong to describe is as she did.

    Forstater was effectively sacked for bullying and harassment.


  10. 16 minutes ago, leapyear said:

    0.3 micrometers is width a femtosecond can get light to travel. 0.3 is around the size of a virus. We can't get a double slit experiment to show us fringes when using viruses.

    I doubt anyone ever tried. And, since viruses come in a variety of sizes, it's clear that you are talking nonsense.

    In fairness, the OP's question is interesting
    186282 miles, 698 yards, 2 feet, and 5+ 21/127 inches per second

    is a weird number.


  11. On 5/23/2019 at 8:09 AM, Sensei said:

     

    Typical way C/C++ programmer is using the most basic C language built-in pseudo-random numbers generator is:

    
    srand( time( NULL ) );
    int value = rand();

    to get value in range in 0....RAND_MAX (0x7fff = 32767)

    Time is input parameter to so called random seed.

    The same seed, the same sequence of numbers returned by rand() function.

    But time (in seconds if returned by time() function) is changing, so each execution output sequence will be different. At least until overflow. srand() takes 32 bit unsigned integer as parameter, so overflow will happen after 2^32 / 60 / 60 / 24 / 365.25 = ~ 136 years (ignoring timezone changes)

    Non-standard pseudo-random number generators typically use current time (better with millisecond/microsecond precision) of machine to initialize random seed (srand()-equivalent function parameter).

     

    So, if I have two computers running at the same time and they both use this method, they will always generate the same "random" number.
    That seems the very antithesis of randomness.


  12. 42 minutes ago, MigL said:

    Just to be a thorn in your side, John :-p ...

    Personal Income tax was introduced in Canada in the year 1917.
    IIRC our Prime Minister from 1911 to 1920 was Sir R Borden, who was a Conservative until the election of 1917, and subsequently a Unionist ( I seem to remember from High School history class ).
    He not only introduced your criteria for liberalism, but also suffrage for women, in 1918.

    Define "Right" and "Left" and also "Liberal" and "Conservative".

    In this context the original use of Liberal meant those who wanted liberal government spending.
    That may or may not have any correlation with a view on personal liberty on matters such as marriage, suffrage etc.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.