• Lethargically Anonymous (unregistered) in reply to brazzy

    brazzy:
    Theoretically, a system that is really unicode-based would have to define a byte as 32 bits because that's how much you need to "hold any member of the basic character set of the execution environment", which is what the standard requires a byte to be able to.

    This word, unicode -- I do not think it means what you think it means.

    (Look up UTF-7, UTF-8, UCS-2, UCS-4.)

  • (cs) in reply to brazzy
    brazzy:

    As I cited before, the C standard (of which the C++ standard is merely an extension) defines a byte as "addressable unit of data storage large enough to hold any member of the basic character set of the execution environment". Since nowadays 1 byte = 8 bit is the norm dictated by hardware makers, but 8 bits are not enough for the charsets we want to use, disregarding this part of the standard is considered a Best Practice, which is basically a language WTF.



    I cut my teeth with a copy of K&R, and I still love C, so please don't consder this C bashing.  When C was written 30+ years ago, it was designed as a language that was somewgat higher level, but could replace assembler.  As such it is great language for OS coding, device drivers, and system programming.  Therefore it is appropriate that the language is tied to hardware.  Any developer doing development in C should have appropriate hardware knowledge.  The true WTF is that C continues to be used to develop applications that are not hardware related.
  • (cs) in reply to Lethargically Anonymous
    Anonymous:

    brazzy:
    Theoretically, a system that is really unicode-based would have to define a byte as 32 bits because that's how much you need to "hold any member of the basic character set of the execution environment", which is what the standard requires a byte to be able to.

    This word, unicode -- I do not think it means what you think it means.

    (Look up UTF-7, UTF-8, UCS-2, UCS-4.)



    Hold on, anonymous.  Brazzy is right.  Unicode indeed requires larger "bytes" in order to map one character per byte.  Those encodings you mention are methods of encoding characters in variant byte lengths.  In a true unicode system, char_count == byte_count.  With these encodings, char_count <= byte_count.
  • (cs) in reply to Otto
    Otto:

    Rank Amateur:
    Wasn't there a bug in Windows like that that forced you to reboot servers after they were left on for about a month?

    Yep. It was 49.7 days, actually, and it went unnoticed for about 4 years.  {...}  It had to do with the Windows Virtual Machine Manager and the Get_System_Time function. One of the things this function did was to load the EAX register with the number of milliseconds since the machine was started. EAX is a 32 bit register. When it looped, the time would reset to zero, and anything calling get_system_time would likely freak out.




     1  day     1 hour       1 minute    1 second   0xFFFFFFFF ms
    -------- x ---------- x ---------- x -------- x -------------- = 49.71 days
    24 hours   60 minutes   60 seconds   1000 ms         1

    which of course is 49 days 17 hours 2 minutes 47 seconds.

    ok
    dpm
  • (cs) in reply to Jon

    Anonymous:
    There seems to be a prevalance of dumb people with no sense of humour who read thedailywtf.com. My request to these dumb people, is please keep posting, I enjoy laughing at you.

    And the best thing is that the dumb people i'm talking about don't even know i'm talking about them.

    Confusicionists would say to other people, you are the dumb person they are laughing at, so keep posting!

  • (cs) in reply to Rank Amateur

    Rank Amateur:
    Wasn't there a bug in Windows like that that forced you to reboot servers after they were left on for about a month?

    Yes, it's called the Windows Kernel, and no known fix is known except for a patch from a 3rd party developer some people know as Linus.

  • (cs) in reply to Lethargically Anonymous
    Anonymous:
    brazzy:
    Theoretically, a system that is really unicode-based would have to define a byte as 32 bits because that's how much you need to "hold any member of the basic character set of the execution environment", which is what the standard requires a byte to be able to.

    This word, unicode -- I do not think it means what you think it means.

    (Look up UTF-7, UTF-8, UCS-2, UCS-4.)

    My computer is tri deuce code, I can run 32 bit applications.  Newer computers are sixpence quad, they run 64 bit code.  I've only heard of dual code computers, based on 2 bits, what is this uni code you speak of?

  • Anonymous (unregistered)

    Holy smokes...just divide milliDiff by 60000.  Who cares about checking for an exception here - when will 60000 ever equal zero?

  • (cs) in reply to RevMike
    RevMike:
    Anonymous:

    This word, unicode -- I do not think it means what you think it means.

    (Look up UTF-7, UTF-8, UCS-2, UCS-4.)



    Hold on, anonymous.  Brazzy is right.  Unicode indeed requires larger "bytes" in order to map one character per byte.  Those encodings you mention are methods of encoding characters in variant byte lengths.  In a true unicode system, char_count == byte_count.  With these encodings, char_count <= byte_count.


    Actually, UCS-2 and UCS-4 are fixed-length encodings, what you call a "true unicode system" (with UCS-2 leaving out some characters). But I'm not sure what HE thinks it means, because what I meant was that if a byte is supposed to be able to hold any one character from the full unicode range, then that byte has to have 32 bit.  Perhaps he was referring to the fact that no more than 24 bits (IIRC) of the 32 bit UCS-4 space have been assigned so far, so 24 bits are theoretically enough, but that wouldn't be a standard Unicode encoding.
  • (cs) in reply to tedbilly
    tedbilly:

    0 / n = 0 // This is NOT a bug in .NET, this is valid math!

    n / 0 = DivideByZero Exception

    In this case his math should be; milliseconds / 60000 = minutes.  If milliseconds is 0 then minutes will be 0 (try it if you don't believe me)



    So the check is wrong. Rather, it should be:

    if (60000 == 0) // Watch out for exceptional value 0
        minutesDiff = 0;
    else
        minutesDiff = (int) (milliDiff / 1000) / 60; // Let's insert a redundant cast just in case

    Some might say this check was superfluous. Nothing could be further from the truth. As stated in Peter 3:8:

    <font class="content"><font class="content">“But forget not this one thing, beloved, that one day is with the Lord as a thousand years, and a thousand years as one day.”

    If thousand years are a day, that means 365000(*) = 1.

    (*) In biblical times, leap years were not yet invented.

    Subtracting one from both sides we get 364999 = 0.

    Multiplying this by 60000/364999, we get 60000 = 0. Furthermore, we can go on to prove that the circle can be squared, the cube doubled, and any angle trisected. QED.

    </font></font>
  • (cs) in reply to Mung Kee
    Mung Kee:

    Is "wanker" passe' now?


    Are acute accents passé now? How do you write "légère"? "le'g'ere"?

  • (cs) in reply to Alexis de Torquemada
    Alexis de Torquemada:


    Are acute accents passé now? How do you write "légère"? "le'g'ere"?



    The trend has been to spell "légère" this way: "lite". Academie and OLF (Office de la Langue Française du Québec) notwithstanding.
  • (cs) in reply to Anonymous
    Anonymous:
    CornedBee:

    Oh, and C++ doesn't throw exceptions on division by zero. The behaviour is implementation-defined: POSIX-based machines will cause a SIGFLT (I think), Windows-based will throw a /0 SEH exception (which is not the same as a C++ exception).


    On x86 machines, divide by zero generates a hardware exception (interrupt 0).


    Which is typically handled by the OS.

  • (cs) in reply to bullestock
    bullestock:

    Bullshit. According to the Holy Standard, the only thing you can be sure of is that
    sizeof(long long) >= sizeof(long) >= sizeof(int) >= sizeof(char).

    So it is perfectly legal to make a compiler where all integral types are 2 bytes, or even 17 bytes.


    According to the Holy Standard, integer types have minimum ranges which require that longs comprise at least 32 bits and long longs at least 64 bits. The only way you could fit either into two bytes is by defining your "byte" to be at least 16 rsp. 32 bits long (the standard doesn't require a particular byte length either).

  • (cs) in reply to travisowens
    travisowens:

    Yes, it's called the Windows Kernel, and no known fix is known except for a patch from a 3rd party developer some people know as Linus.



    It would surprise me a lot if an unknown fix was known.

  • (cs) in reply to Gene Wirchenko
    Gene Wirchenko:
    RobIII:

    I know! I know! I know!
    Ooooh, I have the answer!

    He should AVOID dividing. Dividing is just inverse multiplying!

    milliseconds * 0,0000166666666666667 = Minutes

    No negative/positive checks required, and no chance of encountering "DivideByZeroExecption"!

    [:D][H]


    That might work in your locale, but I think your octal constant has too many digits.  <beg>

    Sincerely,

    Gene Wirchenko



    In any casse, </beg>0000166666666666667 is not an lvalue.

  • (cs) in reply to Alexis de Torquemada
    Alexis de Torquemada:
    RobIII:

    milliseconds * 0,0000166666666666667 = Minutes

    [:D][H]


    <beg> In any case, </beg>0000166666666666667 is not an lvalue.



    Apparently it is a pointer to a value of type "milliseconds".
  • (cs) in reply to RevMike
    RevMike:
    Anonymous:

    brazzy:
    Theoretically, a system that is really unicode-based would have to define a byte as 32 bits because that's how much you need to "hold any member of the basic character set of the execution environment", which is what the standard requires a byte to be able to.

    This word, unicode -- I do not think it means what you think it means.

    (Look up UTF-7, UTF-8, UCS-2, UCS-4.)



    Hold on, anonymous.  Brazzy is right.  Unicode indeed requires larger "bytes" in order to map one character per byte.  Those encodings you mention are methods of encoding characters in variant byte lengths.  In a true unicode system, char_count == byte_count.  With these encodings, char_count <= byte_count.

    My point is that "unicode" does not imply "32 bits".

  • (cs) in reply to Lethargic
    Lethargic:

    My point is that "unicode" does not imply "32 bits".


    If you want a fixed-length encoding (which you do to allow random access to individual characters in a string) and be able to cover the entire range of characters the Unicode standard allows for, it does.
  • (cs) in reply to Alexis de Torquemada
    Alexis de Torquemada:
    travisowens:

    Yes, it's called the Windows Kernel, and no known fix is known except for a patch from a 3rd party developer some people know as Linus.



    It would surprise me a lot if an unknown fix was known.



    It would suprise me a lot if anything unknown was known.
  • (cs) in reply to Anonymoose
    Anonymoose:
    I think we need to start a new sourceforge project, libwtf

    It would be a collection (or perhaps, a collection for each submitted language) of the best entries found here.

    If possible, it should make the compiler (vm, etc...) explode.

    The CVS would need to be set up to not allow edits, we don't want people 'fixing' the code!


    There already is a lib full of wtf's, it's called thedailywtf.dll, and it's in the bin folder of this site.

    i keed i keed :P
  • ihatesmileys (unregistered) in reply to brazzy
    brazzy:

    And highly I recommend referring to the language spec rather than someone's possibly very useful but certainly not official FAQ. As I cited before, the C standard (of which the C++ standard is merely an extension)...

    And I recommend referring to the right language spec.  The C++ standard is NOT an extension of the C standard. It is a totally separate document. C++ is NOT a superset or extension of C. Not everything in C is in C++. Not every C program is a C++ program. The two are DIFFERENT LANGUAGES with DIFFERENT SPECIFICATIONS.

    The real WTF is people like you who spout off like experts on subjects they know very little about.

    <FONT size=2>By the way, am I the only person who thinks that the smileys here are the ugliest smileys on the whole damn intarweb? Seriously, they are hideous. I have nightmares about them.</FONT>

  • (cs) in reply to ihatesmileys

    Anonymous:
    B<FONT size=2>y the way, am I the only person who thinks that the smileys here are the ugliest smileys on the whole damn intarweb? Seriously, they are hideous. I have nightmares about them.</FONT>

    That's because they're undead bran-eating zombies that, by making you have nightmares, forces you to produce WTFs, therefore feeding the site. It's an evil self-preservation circle.

     

    (ok no more halloween movies before sleeping [:)])

  • mfgkw (unregistered) in reply to duck1123
    duck1123:
    ...
    It would suprise me a lot if anything unknown was known.


    The word unknown is well known; at least for me.

    mfgkw
  • g__ (unregistered) in reply to brazzy
    brazzy:
    g__:
    brazzy:

    What irks me is the assumption that 1 byte = one character from a fixed charset.

    It isn't assumed (at least it's not in C++, I assume the same holds true for C). See 26.3 in http://www.parashift.com/c++-faq-lite/intrinsic-types.html

    I highly recommend the book the website forms a subset of for anyone doing C++ work.


    And highly I recommend referring to the language spec rather than someone's possibly very useful but certainly not official FAQ. As I cited before, the C standard (of which the C++ standard is merely an extension) defines a byte as "addressable unit of data storage large enough to hold any member of the basic character set of the execution environment". Since nowadays 1 byte = 8 bit is the norm dictated by hardware makers, but 8 bits are not enough for the charsets we want to use, disregarding this part of the standard is considered a Best Practice, which is basically a language WTF.

    How does that change things? The standard does not say that a byte == a character, but that a byte must be large enough to hold "any member of the basic character set of the execution environment" (and be at least 8 bits IIRC). If the characters you want to use are part of the "basic character set of the execution environment" and don't fit in a byte then the compiler is non-conforming, and that's the vendor's fault (and there's always wchar_t). The fact that (some) hardware makers define a byte as being 8 bits is irrelevant.

  • (cs) in reply to ihatesmileys
    Anonymous:

    And I recommend referring to the right language spec.  The C++ standard is NOT an extension of the C standard. It is a totally separate document. C++ is NOT a superset or extension of C. Not everything in C is in C++. Not every C program is a C++ program. The two are DIFFERENT LANGUAGES with DIFFERENT SPECIFICATIONS.



    Let's hear it from St. Stroustrup himself (citing http://www.research.att.com/~bs/bs_faq.html#C-is-subset ):

    Except for a few examples such as the ones shown above (and listed in detail in the C++ standard and in Appendix B of The C++ Programming Language (3rd Edition)), C++ is a superset of C.

    So yes, there are differences, but they tend to be  not very  relevant. But to satisfy the hair-splitters, I cite ftp://ftp.research.att.com/pub/c++std/WP/CD2/body.pdf (emphasis mine):

    The fundamental storage unit in the C + + memory model is the byte. A byte is at least large enough to contain
    any member of the basic execution character set

    and later:

    The sizeof operator yields the number of bytes in the object representation of its operand. The operand is either an expression, which is not evaluated, or a parenthesized typeid. The sizeof operator shall not be applied to an expression that has function or incomplete type, or to an enumeration type before all its enumerators have been declared, or to the parenthesized name of such types, or to an lvalue that designates a bitfield. sizeof(char), sizeof(signed char) and sizeof(unsigned char) are 1;

    Any further objections?

  • (cs) in reply to g__
    Anonymous:

    How does that change things? The standard does not say that a byte == a character, but that a byte must be large enough to hold "any member of the basic character set of the execution environment"


    That, combined with defining char to be 1 byte in size, looks to me very much like "a byte == a character". Why else say it?

    Anonymous:

    (and be at least 8 bits IIRC). If the characters you want to use are part of the "basic character set of the execution environment" and don't fit in a byte then the compiler is non-conforming, and that's the vendor's fault (and there's always wchar_t). The fact that (some) hardware makers define a byte as being 8 bits is irrelevant.


    Try making and selling a compiler that is truly compliant on a unicode-based system (such as Windows XP is supposed to be IIRC) and therefore defines it bytes to have 16 or 32 bits. Note the flames, ridicule and no success whatsoever that will result. Ponder the difference between theory and the real world in relation to relevance.

  • (cs) in reply to brazzy
    brazzy:
    g__:

    How does that change things? The standard does not say that a byte == a character, but that a byte must be large enough to hold "any member of the basic character set of the execution environment"


    That, combined with defining char to be 1 byte in size, looks to me very much like "a byte == a character". Why else say it?

    But it depends on what you define 'character' as, and you appear to be defining it to mean any character you want to use, which is not what the standard defines it as; the standard does not explicitly state that byte == character to allow implementors flexibility. There are compilers for DSP chips where a byte is defined as 32 bits (as are shorts, longs, etc.), so a char can hold characters that require (for example, not exclusive) 8, 16, 24 or even 32 bits. In such a situation, does byte == character? If so, which one?

    brazzy:
    g__:

    (and be at least 8 bits IIRC). If the characters you want to use are part of the "basic character set of the execution environment" and don't fit in a byte then the compiler is non-conforming, and that's the vendor's fault (and there's always wchar_t). The fact that (some) hardware makers define a byte as being 8 bits is irrelevant.

    Try making and selling a compiler that is truly compliant on a unicode-based system (such as Windows XP is supposed to be IIRC) and therefore defines it bytes to have 16 or 32 bits. Note the flames, ridicule and no success whatsoever that will result. Ponder the difference between theory and the real world in relation to relevance.

    The execution environment is up to the implementor; just because the OS supports Unicode doesn't mean that the execution environment has to. As for the flames, etc. perhaps you can point out such a case that has occurred, and where the failure was due to this decision, otherwise that's just your opinion [:)]; I will note that for a compiler to succeed (on the Windows platform) there are, in my opinion, a lot of issues other than compliance that will determine success (cf Borland vs Microsoft for one example).

    As an aside, I don't disagree that char, wchar_t, Unicode / etc. support and the whole bytes vs characters thing is confusing (and the whole Unicode and other non-ASCII standards appears a bit of a mess anyway, regardless of platform or language), but I do disagree that the standard assumes byte == character.

  • Rupert (unregistered) in reply to Rank Amateur

    Windows 98 would spontaneously reboot every 49.7 days, if you could get it to stay up that long. That's 2^32 milliseconds, so some timer was hitting an overflow.

  • (cs) in reply to Rupert

    Anonymous:
    Windows 98 would spontaneously reboot every 49.7 days, if you could get it to stay up that long. That's 2^32 milliseconds, so some timer was hitting an overflow.

    <FONT face="Courier New" size=2>damnit, rupert, not here!</FONT>

  • (cs) in reply to g__
    g__:

    As an aside, I don't disagree that char, wchar_t, Unicode / etc. support and the whole bytes vs characters thing is confusing (and the whole Unicode and other non-ASCII standards appears a bit of a mess anyway, regardless of platform or language), but I do disagree that the standard assumes byte == character.


    IMO it does in its definition of byte. Even if it's not a realy equality, it makes a strong connection where none should exist, and IMO this is exactly the kind of thinking, common at the time C was created, that resulted in the mess of encodings (and inexperienced coders' penchant for storing binary data in strings): "We know how the characters we need to use map to bytes in our system, and that's all we need." If only they'd gotten together and come up with Unicode two decades earlier, everything could have been SO MUCH easier...

    Most of the character encodings are quite sensible, it's only their multitude that creates a mess... and those that aren't sensible are usually so because they tried/had to be compatible to another encoding.

    A particularly nasty example is Japanese, where your have ISO-2022-JP, which is a MODAL(!!!) encoding commonly used for email, while for most other files you use the Microsoft-endorsed Shift-JIS, which is a horrible mess resulting from having the first of each of its two bytes per character compatible to the older JIS X 0201 encoding, which in turn was the result of shoehorning a minimal subset of Japanese characters (so-called "half-width katakana", a syllabic alphabet) into an ASCII derivate. Nobody who has a choide uses those half-width katakana anymore, but they still have to deal with a messy encoding because of them, and of course they also turn up in Unicode along with the regular katakana.

  • The Frog (unregistered)

    [pi] With all that codeing and it still can't handle the min long case.
    (i.e. with 2's complement arithmatic - 0 = 0 and - min(signed type) = min(signed type)

     

  • (cs) in reply to Rank Amateur

    Rank Amateur:

    Worse than that. 2^15 minutes is only about 23 days, so overflow hits at about 2 billion (US) milliseconds.

    I may be showing my ignorance here, but is there a difference between a US millisecond and a millisecond in other parts of the world? Or is it 'billion' that has a different meaning in the US? [^o)]

  • (cs) in reply to redtetrahedron
    redtetrahedron:

    Rank Amateur:

    Worse than that. 2^15 minutes is only about 23 days, so overflow hits at about 2 billion (US) milliseconds.

    I may be showing my ignorance here, but is there a difference between a US millisecond and a millisecond in other parts of the world? Or is it 'billion' that has a different meaning in the US? [^o)]



    The latter. In the US a billion = 10^9, whereas in the UK, a billion used to be 10^15, though this usage is becoming less common.  It's still the norm in many other languages, and in that system, 10^9 is called "a thousand million" or "a billiard(e)". Both were invented by the French, incidentially.

  • (cs) in reply to brazzy
    brazzy:

    The latter. In the US a billion = 10^9, whereas in the UK, a billion used to be 10^15, though this usage is becoming less common.  It's still the norm in many other languages, and in that system, 10^9 is called "a thousand million" or "a billiard(e)". Both were invented by the French, incidentially.


    Oops, two mistakes. It's 10^9 = "milliard", 10^12 = "billion", 10^15 = "billiard", etc. in the "long scale" system.
  • bolean value dude (unregistered) in reply to limelight

    ur all a bunch of nnnnnnnnnnnnnnneeeeeeeeeeeerrrrrrrrdddddzzzzzzz

  • bobbyG (unregistered) in reply to duck1123
    It would suprise me a lot if anything unknown was known.

    As we know, There are known knowns. There are things we know we know. We also know There are known unknowns. That is to say We know there are some things We do not know. But there are also unknown unknowns, The ones we don't know We don't know.

    ....poetry of The great Donald Rumsfeld.

Leave a comment on “The Millisecond Converter”

Log In or post as a guest

Replying to comment #:

« Return to Article