Thread: Converting 1100110.11 to base10

  1. #76
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    Quote Originally Posted by Mario F. View Post
    III.MCDXV
    or even,
    X.XXMCDXV
    Extraordinary ( and pretty cool )!!
    Devoted my life to programming...

  2. #77
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    My gift for all you notation liberals in here.
    According to you and quzah since you didn't specifically declare what interpretation to apply and C wouldn't handle those apparently values natively they are meaningless and shouldn't be discussed on a C programming forum and any guess of a given interpretation should be met with contempt.

    Soma

  3. #78
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Quote Originally Posted by quzah View Post
    because nothing you ever do with binary numbers in C uses a decimal point.
    Learning about binary representation of fractions is very important to understand the nature of IEEE floating points. What fractions can be represented exactly? When do we get round-off errors?
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  4. #79
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Sang-drax View Post
    Learning about binary representation of fractions is very important to understand the nature of IEEE floating points. What fractions can be represented exactly? When do we get round-off errors?
    Why on earth would it be important? It's obvious that if you want accuracy in C, you don't use floating point numbers. You don't need to know anything about floating point numbers beyond that. You aren't ever going to use them for anything critical, so who cares what can be represented?


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #80
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by phantomotap View Post
    According to you and quzah since you didn't specifically declare what interpretation to apply and C wouldn't handle those apparently values natively they are meaningless and shouldn't be discussed on a C programming forum and any guess of a given interpretation should be met with contempt.

    Soma
    The difference here is that the above wasn't posted on the C board, asking how to convert it to base 10. Also, it isn't "obvious" by looking at it that it could fall into multiple base types. As much as itsme86 wants it to be clear, it is only guessing as what base the first one is in, because you have a 20% chance per digit, in any base 10 number you write to end up with something that "is obviously binary!"

    0
    1
    10
    11
    100
    101
    110

    Which one of those numbers was binary again?


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #81
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    Look, to get it over with! Math say that every number has a base that must be written as index right after that number. Because 10 is the most used, add of index(10) is omitted. Therefore, if we encounter a number between 0-9 without a base, its base is 10! Every base can have fractions!

    Now, for C/C++. 10 is decimal, 010 is octal, 0x10 is hexadecimal! Where's the problem?

    So, quzah, none of them is binary!
    Devoted my life to programming...

  7. #82
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Sipher View Post
    Now, for C/C++. 10 is decimal, 010 is octal, 0x10 is hexadecimal! Where's the problem?

    So, quzah, none of them is binary!
    Ah, so according to you, the first number we were asked to convert to base 10, was already in base 10. Thanks for playing!


    Quzah.
    Hope is the first step on the road to disappointment.

  8. #83
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Quote Originally Posted by quzah View Post
    Why on earth would it be important? It's obvious that if you want accuracy in C, you don't use floating point numbers. You don't need to know anything about floating point numbers beyond that. You aren't ever going to use them for anything critical, so who cares what can be represented?
    Now I almost think you're trolling. To me, it is obvious that a thorough understanding of floating point number beyond "if you want accuracy, don't use floating point numbers" can be very useful.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  9. #84
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Sang-drax View Post
    Now I almost think you're trolling. To me, it is obvious that a thorough understanding of floating point number beyond "if you want accuracy, don't use floating point numbers" can be very useful.
    I can't possibly see how this would be useful. Maybe my brain just doesn't work like yours does, but I can't ever see how looking at a floating point number, then mentally going through the process of how floating point numbers are stored, to see if this would be a valid number or not for my program, could ever be useful to me.

    Why would you want to get into the situation where you have to manually analyze each floating point number to decide if it's going to fit right in your data type, or if it isn't going to be accurate enough?


    Quzah.
    Hope is the first step on the road to disappointment.

  10. #85
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Because you want to go to Mars.

  11. #86
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by tabstop View Post
    Because you want to go to Mars.
    And why would I use floating point numbers that are inherently inaccurate in something that was going to get me to mars, when I can just use ints instead, and not have to worry about any stupid rounding errors that will cause me to slam into the ground, or shoot off into the sun?


    Quzah.
    Hope is the first step on the road to disappointment.

  12. #87
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by tabstop View Post
    Because you want to go to Mars.
    I was reading the other day that you only needed to calculate Pi to the 32nd decimal place to be able to drawn a circle the size of the known universe with the precision of an hydrogen atom... or something like that. You can understand if a trip to Mars won't even require that. We went to the Moon on a fixed point unit, 2 KB memory and 32 KB storage.

    Curiously enough though, this argument only reinforces the need to observe binary representations in the context of how they are actually stored. Precision has a direct relationship with data types, and the way these numbers are stored has a direct impact on what data types we must choose. Something that the OP notation completely hides from the programmer. There's really no benefit on representing binary in any other way than how it is stored. For any concrete use, that representation would then have to be converted again. From binary to binary. Doesn't seem useful or practical.

    I'm still a bit shocked that there's an argument for things like 11001.101 in such an established programming forum like this (especially when we aren't even told what is the actual notation being used). But I shouldn't be surprised anymore. In a society where everything wants to be relativized, there's always someone wanting to take their chance at the few areas still dominated by formal rules. Often oblivious to the fact certain values or principles are lost. In short, anything goes.
    Last edited by Mario F.; 02-07-2011 at 08:22 PM.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  13. #88
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Mario F. View Post
    I was reading the other day that you only needed to calculate Pi to the 32nd decimal place to be able to drawn a circle the size of the known universe with the precision of an hydrogen atom... or something like that. You can understand if a trip to Mars won't even require that. We went to the Moon on a fixed point unit, 2 KB memory and 32 KB storage.
    On average Mars is 200 million km away. If you are off by an angular measurement of 2^-32 radians, you'll be off by 46 meters at the other end. Which obviously is still acceptable for pretty much anything, naturally.

    Of course you're not going to be any more than 46 meters accurate using an int, either, unless you up the storage size of the int (since presumably you will just be using units of 2^(-negative power) radians there anyway). You will just think you are, unless you pay attention to the results you get. (I was having fun the other day breaking calculators on the Ipad that were perfectly willing to show you 50-digit numbers as though they were exact integers, but many of the digits were wrong because their internal data structure wasn't up to the task.) Using int is exactly the same as using fixed-point, really; you're just hiding the fixed-point in the unit definition.

  14. #89
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    As Sang-drax said, maybe the teacher was trying to teach representation to show that some numbers are inherently impossible to represent. That would be a good lead in to why that, if you add .1 10 times, it won't, in nontrivial cases, equal 1 in practice.

  15. #90
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    This thread has been fun!

    Quote Originally Posted by quzah View Post
    Why on earth would it be important? It's obvious that if you want accuracy in C, you don't use floating point numbers. You don't need to know anything about floating point numbers beyond that. You aren't ever going to use them for anything critical, so who cares what can be represented?


    Quzah.
    Now that's just silly. Please show me trigonometric functions like sine, cosine, tangent, using only integers as arguments and giving integers as result. Oh and they can't use anything but integers internally as well. Or logarithms, exponentiation, etc.

    Of course one uses floating point for critical applications. One just has to understand the limitations, if any manifest themselves. In short error analysis.

    I've heard your argument used in banks... that "fixed point" notation should be used to do all money calculations. I wonder how they ever manage to do interest calculations then.

    I guess we'll all just scrap division too because it could make non-integer results.
    Last edited by nonoob; 02-08-2011 at 10:16 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting decimals to individuals
    By clag in forum C Programming
    Replies: 27
    Last Post: 10-03-2009, 03:08 PM
  2. Replies: 1
    Last Post: 09-20-2009, 07:39 AM
  3. Converting Sign Magnitude Integer Binary Files
    By Arthur Dent in forum C Programming
    Replies: 7
    Last Post: 09-13-2004, 10:07 AM
  4. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  5. converting string to float
    By twhubs in forum C Programming
    Replies: 1
    Last Post: 09-16-2001, 09:02 AM