Convert Varchar field

  • There most certainly was a decimalised half penny. I'm not old enough to remember pre-decimal currency, but I am old enough to remember being gutted that half-penny sweets were about to become effectively double the cost (which never actually happened, they were sold in pairs, but a child's mind doesn't work like that) in 1984.

    https://en.wikipedia.org/wiki/Halfpenny_(British_decimal_coin)

  • andycadley - Wednesday, August 29, 2018 10:35 PM

    There most certainly was a decimalised half penny. I'm not old enough to remember pre-decimal currency, but I am old enough to remember being gutted that half-penny sweets were about to become effectively double the cost (which never actually happened, they were sold in pairs, but a child's mind doesn't work like that) in 1984.

    https://en.wikipedia.org/wiki/Halfpenny_(British_decimal_coin)

    I remember getting 1/2 pennies when I would go of base while stationed in England between 1979 and 1981.  The odd shaped coins, the different sized bills, actually quite interesting for a young airman from across the pond.

  • TomThomson - Tuesday, August 28, 2018 5:49 AM

    jcelko212 32090 - Friday, August 24, 2018 12:58 PM

    Many decades ago, I was consulting at Coca-Cola in Atlanta. They were trying to convert COBOL over to PL/1 because it was the new cool super language. Since I'd taken computer classes at Georgia Tech, I knew Algol (the school was on a Burroughs 5500) , so my code was pretty good. Other programmers took advantage of this super language being able to be used COBOL or Fortran style. Their code frankly was pretty awful for a block structured language.

    I really hated PL/1 because I thought it was overly complicated, and produced code that was about three times the size of the COBOL it was replacing. Apparently the IBM salesman for Coca-Cola the hell of a good job of selling extra hardware. Then after all that bitching I wound up working for DOD and learning ADA before there were even any compilers for it. I guess it could've been worse; somebody actually wrote in Algol 68 compiler over in the UK. I really hate super languages 🙁

    Actually there were at least 4 Algol 68 compilers built in Britain. The UK end of Burroughs built an Algol 68 compiler (which did, I believe, get used by the US end) and implemented a mainframe operating system in it - but I don't think it was the whole language.  ICL built two Algol 68 compilers - also not the whole language - for a subset known in ICL as S3, the second one being a replacement for the first one, and again used it to write a series of mainframe operating systems plus quite a bit of middleware (including a bolt-on for IDMS-X that allowed it to be queried - but not written to - in SQL).  And I heard about a compiler for the complete Algol 68 language, but I can't remember who did it. After Fujitsu bought ICL the operating system and the language both continued to be used in Fujitsu, who still sell the OS and sometimes look for S3-capable developers.

    It's not a super-language in the sense of a horrible overcomplicated mess like PL/1 or something throughly declarative - like Haskell or Prolog - (and therfore utterly alien to developers who know only very undeclarative languages such as C++ and PL/1), so I don't see why you call it a super-language; it's extremely simple to learn if you already know one of the earlier Algols (Algol 58, Jovial, Algol 60) - back in 1971 it took me and hour or two to read and understand the user handbook, and then I could learn what was effective by coding things in a few different ways and seeing how they compared on (a) easiness to understand, (b) storage used, (c) performance.

    Learned a little ALGOL 68 on a DEC System 11 during a teacher strike in 1976 while in high school.  An interesting language actually.

  • Jonathan AC Roberts - Tuesday, August 28, 2018 4:23 PM

    Jason A. Long - Tuesday, August 28, 2018 4:04 PM

    orig_string_val  decimal_number
    -------------------- ---------------------------------------
    1"     1.000000000000000
    3/4"    0.750000000000000
    11/2"    1.500000000000000
    13/4"    1.750000000000000
    333/4"    33.750000000000000
    789"    789.000000000000000
    998/9"    99.888888888888888
    499/64"   49.140625000000000
    888/999"   0.888888888888888

    Hope this helps,
    Jason

    I don't understand why you convert 11/2 to be 1.5? I could see it if there were a space i.e. 1 1/2 but 11/2 is 6.5

    The original problem was at some point clarified that it could NEVER be a situation where the numerator was larger than the denominator.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • sgmunson - Thursday, August 30, 2018 5:34 AM

    Jonathan AC Roberts - Tuesday, August 28, 2018 4:23 PM

    Jason A. Long - Tuesday, August 28, 2018 4:04 PM

    orig_string_val  decimal_number
    -------------------- ---------------------------------------
    1"     1.000000000000000
    3/4"    0.750000000000000
    11/2"    1.500000000000000
    13/4"    1.750000000000000
    333/4"    33.750000000000000
    789"    789.000000000000000
    998/9"    99.888888888888888
    499/64"   49.140625000000000
    888/999"   0.888888888888888

    Hope this helps,
    Jason

    I don't understand why you convert 11/2 to be 1.5? I could see it if there were a space i.e. 1 1/2 but 11/2 is 6.5

    The original problem was at some point clarified that it could NEVER be a situation where the numerator was larger than the denominator.

    Where was that then? I saw the OP wanted to convert the fraction to an integer but I didn't see anything about it not being top heavy.

  • andycadley - Wednesday, August 29, 2018 10:35 PM

    There most certainly was a decimalised half penny. I'm not old enough to remember pre-decimal currency, but I am old enough to remember being gutted that half-penny sweets were about to become effectively double the cost (which never actually happened, they were sold in pairs, but a child's mind doesn't work like that) in 1984.

    https://en.wikipedia.org/wiki/Halfpenny_(British_decimal_coin)

    Yes, but neither the predecimal halfpenny nor the predecimal farthing was there during the run up to decimalisation and I read crmitchell's comment as stating that they were both still used in the predecimal system all the way up to the time of decimalisation In fact neither was legal tender after the halfpenny was de-monetised in 1969 and decimalisation took place in 1971.  And almost everyone in 1971 called the decimal coin a half-p, although the official name was halfpenny. 
    The last surviving pre-decimal coin was the sixpence, which remained in circulation until 1980.

    Tom

  • TomThomson - Thursday, August 30, 2018 7:08 AM

    andycadley - Wednesday, August 29, 2018 10:35 PM

    There most certainly was a decimalised half penny. I'm not old enough to remember pre-decimal currency, but I am old enough to remember being gutted that half-penny sweets were about to become effectively double the cost (which never actually happened, they were sold in pairs, but a child's mind doesn't work like that) in 1984.

    https://en.wikipedia.org/wiki/Halfpenny_(British_decimal_coin)

    Yes, but neither the predecimal halfpenny nor the predecimal farthing was there during the run up to decimalisation and I read crmitchell's comment as stating that they were both still used in the predecimal system all the way up to the time of decimalisation In fact neither was legal tender after the halfpenny was de-monetised in 1969 and decimalisation took place in 1971.  And almost everyone in 1971 called the decimal coin a half-p, although the official name was halfpenny.  The longest lasting pre-decimal coin was teh sixpense, which remained in circulation until 1980.

    Best thing we did was getting rid of the half crown.
    Often got conned out of a tanner when the shopkeeper claimed you'd given them 2 bob.

  • Jonathan AC Roberts - Thursday, August 30, 2018 5:40 AM

    sgmunson - Thursday, August 30, 2018 5:34 AM

    Jonathan AC Roberts - Tuesday, August 28, 2018 4:23 PM

    Jason A. Long - Tuesday, August 28, 2018 4:04 PM

    orig_string_val  decimal_number
    -------------------- ---------------------------------------
    1"     1.000000000000000
    3/4"    0.750000000000000
    11/2"    1.500000000000000
    13/4"    1.750000000000000
    333/4"    33.750000000000000
    789"    789.000000000000000
    998/9"    99.888888888888888
    499/64"   49.140625000000000
    888/999"   0.888888888888888

    Hope this helps,
    Jason

    I don't understand why you convert 11/2 to be 1.5? I could see it if there were a space i.e. 1 1/2 but 11/2 is 6.5

    The original problem was at some point clarified that it could NEVER be a situation where the numerator was larger than the denominator.

    Where was that then? I saw the OP wanted to convert the fraction to an integer but I didn't see anything about it not being top heavy.

    Oops!   Looks like mental convergence messed up my recall.   However, as neither top-heavy fractions nor non-top-heavy fractions are devoid of the possibility of ambiguity,
    I'm inclined to call the problem inherently unsolvable in anything but a limited way, and only with the possibility that ambiguity could still rear it's ugly head.   I, for one, would
    not allow any organization I was a part of to accept it as viable input.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • sgmunson - Thursday, August 30, 2018 9:57 AM

    Jonathan AC Roberts - Thursday, August 30, 2018 5:40 AM

    sgmunson - Thursday, August 30, 2018 5:34 AM

    Jonathan AC Roberts - Tuesday, August 28, 2018 4:23 PM

    Jason A. Long - Tuesday, August 28, 2018 4:04 PM

    orig_string_val  decimal_number
    -------------------- ---------------------------------------
    1"     1.000000000000000
    3/4"    0.750000000000000
    11/2"    1.500000000000000
    13/4"    1.750000000000000
    333/4"    33.750000000000000
    789"    789.000000000000000
    998/9"    99.888888888888888
    499/64"   49.140625000000000
    888/999"   0.888888888888888

    Hope this helps,
    Jason

    I don't understand why you convert 11/2 to be 1.5? I could see it if there were a space i.e. 1 1/2 but 11/2 is 6.5

    The original problem was at some point clarified that it could NEVER be a situation where the numerator was larger than the denominator.

    Where was that then? I saw the OP wanted to convert the fraction to an integer but I didn't see anything about it not being top heavy.

    Oops!   Looks like mental convergence messed up my recall.   However, as neither top-heavy fractions nor non-top-heavy fractions are devoid of the possibility of ambiguity,
    I'm inclined to call the problem inherently unsolvable in anything but a limited way, and only with the possibility that ambiguity could still rear it's ugly head.   I, for one, would
    not allow any organization I was a part of to accept it as viable input.

    How can a top heavy fraction have an ambiguous value?

  • Jonathan AC Roberts - Thursday, August 30, 2018 10:03 AM

    How can a top heavy fraction have an ambiguous value?

    Easy.  91/2 might not actually be top heavy, and could be 9 and 1/2.   Top heavy fractions are extremely unlikely to begin with, and where they do exist, are probably
    going to be mixed with NON top-heavy ones.   I would never sign up to convert fractions without separators.   Period.  Just wouldn't allow it through, EVER.   Too much
    trouble to support breakages.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • TomThomson - Wednesday, August 29, 2018 6:11 PM

    crmitchell - Wednesday, August 29, 2018 9:53 AM

    paul s-306273 - Wednesday, August 29, 2018 8:24 AM

    crmitchell - Wednesday, August 29, 2018 7:42 AM

    Joe,
    in the UK we used thou for tight tolerance engineering but the fractional nomenclature was commonplace.
    There were also coins smaller than a penny - plural pennies not pence - the halfpenny and the farthing (1 quarter penny) were still in use at decimalisation in 1971 although there were smaller denomination coins at earlier times usually using binary fractions but there were some decimal coins at some points . After that the new coin was called a "new pence" to differentiate it from the pre decimal "penny" although it commonly was (and still is) called a penny.
    If you really want to give your students a challenge have them use guineas (21 shillings to the guinea) rather than pounds and throw in a few tanners, groats, crowns and florins into the pay packet.

    Sixpence piece? Tuppence ha'penny? Threepenny bit?
    Think we had pence as well as pennies.

    tuppence is a decimal coin - there may have been some half groat coins at some time but generally the next coin up from the penny was the thru'p'ny .bit.
    sixpence was the name of the coin commonly called a tanner or a half bob - you could change it to 6 pennies or 2 1/2 new pence. the 1d coin was called the penny not a pence.

    There's so much wrong there!  Halfpennies and farthings were not in use at decimalisation in 1971 - that's pure nonsense.   The history of Brtish coinage/currency is very well documented; and there are pleny of us still around who were old enough to be married and have children and have to worry about money back in 1971 who noticed what happened then, and as a result can explain to you how wrong you are.  It appears that we also speak an English language that it is foreign to you, as "pence" was an accepted plural for "penny" when discussing value (as opposed to penny coins) when I first learnt the words, more that 20 years before 1971.
    Halfpenny coins ceased to be legal tender in 1969.  The last halfpenny coins that were legal tender were minted in 1967.   In 1970 a set of souvenir halfpenny pseudocoins were minted as souvenirs of the predecimal age - these were never legal tender.
    The halfpenny coin ceased to be something that could be used to pay in 1969, two years before 1971 - it was alreasy no longer British currency 2 years before 1971.
    Farthing coins ceased to be legal tender in 1960.  They were last minted in 1956.  They were certainly not British currency all the way up to 1971.
    Tuppence can indeed mean a decimal coin.  However, throughout the 19th centurey and in the twentieth century until 1971 (and in practise for a good time afterwards) it meant a value/price/cost, not a coin, of one sixth of a shilling, 
    You seem not to distinguish between the name of a coin and the name iof its value.  A penny was a coin. It was also a value.  The two meanings had different plurals.  Three pence meant three penny coins.  Threpence meant the value of 3 penny coins or of one threpenny bit.  People said "three hapence" for a value/price/cost of one and half pennnies but when they were referring to an out of date bicycle (whose wheels were different sizes, as were a penny and a halfpenny) they said "penny halfpenny" because the bike's wheels were in the proportion of the coins.
    Your last few words seem to suggest that you call a 1p coin "a pence" - well, most of us call it a penny.   It's worth a lot less than a old-style penny in 1971, of course: 1d 1971 = 4.118p 2018 on the most optimistic estimate (the one chosen by politicians who want to pretend we are so much better off that we actually are) , but it's nearer to 12.5p if we measure by the typical price of a pint of bitter in a pub and even more if we look at the price of milk or at house prices and rents.

    Good to see I'm not the only one to get bits wrong - I was just starting school at decimalisation so my memory isn't perfect.

    Sixpence was not the last pre decimal coin to cease to be legal tender - the shilling remained legal tender for 10 years after that until 1990 and the florin a further 3 years until 1993. There are also double florins, crowns and sovereigns which were released as commemorative coins but remain legal tender - not that anyone would spend them. Maundy money issued prior to decimalisation also remains legal tender but was revalued to its face value in new pence - again you wouldn't spend it as its value as a collectible far exceeds its face value.

    No I wouldn't call the 1p coin a pence, i'd call it a 1p or a penny like most, but officially it was a 1 new pence - take a look at what is written on it - or at least on one more than a very few years old

  • crmitchell - Thursday, August 30, 2018 10:45 AM

    Good to see I'm not the only one to get bits wrong - I was just starting school at decimalisation so my memory isn't perfect.

    Sixpence was not the last pre decimal coin to cease to be legal tender - the shilling remained legal tender for 10 years after that until 1990 and the florin a further 3 years until 1993. There are also double florins, crowns and sovereigns which were released as commemorative coins but remain legal tender - not that anyone would spend them. Maundy money issued prior to decimalisation also remains legal tender but was revalued to its face value in new pence - again you wouldn't spend it as its value as a collectible far exceeds its face value.

    No I wouldn't call the 1p coin a pence, i'd call it a 1p or a penny like most, but officially it was a 1 new pence - take a look at what is written on it - or at least on one more than a very few years old

    The situation for 6d,  1/- and 2/- coins was rather weird.  The 6d coin was given a reprieve because the declared intention to kill it on day 1 raised sufficient outcry that it looked as if it would be electorally damaging.  And you are right, I'd forgotten the special treatment of the shilling and florin.
    The 5p and 10p coins were introduced into circulation before 1971 (about 3 years efore "decimal day", and after their introduction although shillings and florins remained in circulation banks were not allowed to pay them out - the idea being twofold: (a) the 5p and 10p coints were the same size shape and weight as the corresponding pre-decimal coins, so having them around early would familiarise people with at least 2 of the new coins without creating any problems and (b) with the banks accepting the old coins but only paying out the new ones the old coins in circulation would eventually become few enough that the pain of demonetizing them would be much less - so they did as you say continue to be legal tender for 19 years and 22 tears respectively, when the introduction of smaller 5p and 10p coins would have created confusion and the Bank of England and the Treasury decided that there were so few left in circulation that they could be demonetized without creating a problem.

    Because the old penny and threpence were effectively incompatible with the new system, shops were required from 15th Feb 71 to accept both pre-decimal currency and decimal currency but to provide change only in decimal currency (including 6d, 1/- and 2/- coins which counted as decimal for this ourpose) until 31st August 1971 when the old penny and threpenny bit were demonetized (this also applied to rail, bus, and tube but from slightly different start dates). 

    The sixpence was finally demonetized at the end of June 1980, without being replaced by a 2.5p decimal equivalent, as inflation had been so great in the 70s that it wasn't worth having another coin between 2p and 5p).  It too was taken by banks but not paid out by banks, from 15 Feb 71 (I think - but maybe it started at the same time as for the shilling and florin, or maybe some other date) onwards, to reduce the number of 6d coins in circulation as quickly as possible.
    Half crown coins were demonetized were demonetized in January 1970, more than a year before decimal day.

    Tom

Viewing 12 posts - 31 through 41 (of 41 total)

You must be logged in to reply to this topic. Login to reply