Convert/Cast Single to double inaccurate.

Whilst I have read some background on floating opint numbers not being able to accurately store numbers such as 0.1, I am not clear why converting from single to double is so inaccurate.
Converting a single 0.1 to a double 0.1 yeilds
0.10000000149011600
But 0.1 can be represented in a double more accurately, even if not perfectly as
0.10000000000000000
This stems from the single representation of 0.1 actually equating to 0.10000000149011600 in binary.
However, we know that the single has a particular level of precision.
I would like a conersion function that converts single 0.10000000 to double 0.1000000000000000.
I can appreciate that the standard conversion functions would need to still exist as real numbers for engineering would suffer less overall inaccuracies with the existing rounding functions.
One other question:
Can the convertsion be affected by the OS/framework/hardware or will it be consistent on different machines?  Are there any settings that can change the conversion behaviour?

There is no reason that we should explicitly convert a single precision number to a double precision number using some function as a simple assignment would do the same. Please review the following code:
float x = 10.5367f;
double a = Convert.ToDouble(x);
double b = (double)x;
double c = x; //same as conversion or casting
In the previous example, when x is declared as float, the memory space that is allocated is sufficient to hold the value of x as float along with precision. Now when we assign the value to some double variable (by conversion/casting/direct assignment), all
what happens is,
1. the space for the double variable is allocated
2. the value is copied from single the single variable to double variable.
Now obviously, the value of the single variable does not span as much memory space as the double variable. So when copied to double the remaining memory space of the double variable is still filled up with garbage data. The actual value of the single variable
is still preserved upto the range of single precision.
So frankly speaking, there is no such straightforward way that can be used to fill the garbage digits with 0s.
I personally recommend that you use "decimal" instead of "double" if any such conversion is required.
Thanks.

Similar Messages

  • Outlook 2010 apostrophe, single and double quotes are changes to question mark while sending mails to other internet receipient.

    We are using MS Outlook 2010 as our mail client. But we have noticed that whenevr we sent a mail to any other internet mail recipient all the "apostrophe", "single" and "double quotes" have automatically converted to ?. We have
    done almost all the workaround found in this site such as
    1.New a message and focus on the message window > click File > Options > Mail > Spelling and Autocorrect… > Proofing > AutoCorrect Options… > AutoFormat > clear the box before “Straight quotes” with “smart quotes”
    2. Used different encoding. We presently using US-ASCII for outgoing message. etc.
    Need your help to sort out these issues urgently.
    Waiting for a solution.

    Hi,
    What is your account type? IMAP, POP or Exchange?
    Send an email from the webmail, ask the recipient if this issue persists.
    As far as I know, this problem is always related to the encoding for outgoing messages, and here I suggest you try UTF-8:
    Go to File -> Options -> Advanced -> International options -> Uncheck "Automatically select encoding for outgoing messages", then select "Unicode (UTF-8)" beside "Preferred encoding for outgoing messages" -> OK.
    Hope this helps.
    Regards,
    Melon Chen
    TechNet Community Support

  • I want to cast Array to double[]

    I make an windowsForm class for draw graph.
    It has an input param
    public FormGraph(string title, string name1, Array data1)
    I need data of double[] type for draw graph. But I think users are want to input double[] or int[] ect...
    So I try to get data as Array type and cast it to double[].
    double[] series1 = (double[])data1;
    But it throw exception about fail to cast.
    How can I cast variable type of array to double[]?

    Another option is to combine Generics with this.
    You can use generics to allow the users to pass different types of data to a method, but type specific in a different way.
    public FormGraph<T>(string title, string name1, IEnumerable<T> data1)
    var series1 = data1.Select(x => Convert.ToDouble(x)).ToArray();
    Muthukrishnan Ramasamy
    net4.rmkrishnan.net
    Use only what you need, Reduce global warming

  • When i try to upload a .mts file from my Sony camera to Premiere Pro CC it refuses to play the audio! Ofcourse i could convert every single clip but it takes tons of time. How can i make Pr play audio track properly?

    When i try to upload a .mts file from my Sony camera to Premiere Pro CC it refuses to play the audio! Ofcourse i could convert every single clip but it takes tons of time. How can i make Pr play audio track properly?

    Does it not play at all or cannot you get the audio in the timeline?
    Did you copy the entire card to the hdd and then imported the file via the Media Browser?
    Did you source patch the audio tracks?

  • I recently signed up for a one month trial of adobe pro.  I logged in.  I cannot convert a single page of PDF file to word or Excel with this trial.  I just get the request to sign up for a year.  What good is the trial if I can't try it?

    I recently signed up for a one month trial of adobe pro.  I logged in.  I cannot convert a single page of PDF file to word or Excel with this trial.  I just get the request to sign up for a year.  What good is the trial if I can't try it?

    Hey vcomfort6,
    Please ensure that you are using Adobe Acrobat and not Reader to convert PDF file to word or excel.
    Could you tell me whether it is a scanned document? Does this happen with all PDFs or any specific one?
    Do you get any error message? What exactly happens when you try doing the same?
    Hope to hear from you.
    Regards,
    Anubha

  • Converting a single space between sentences with two spaces.

    Hi,
    I'd like to convert all single whitespaces after a sentence to two whitespaces, e.g. This is a sentence! The next sentence is separated by two spaces. This would result in the conventional style of two spaces between sentences, unlike html style. I want to find either a .,?, or ! followed by one whitespace, followed by a capital letter, so: "[.|?|!] [A-Z]". Then I want to just replace this with the same thing except two spaces. If I do this:
                        textString = textString.replaceAll(". [A-Z]", ". [A-Z]");
    it finds these matches, but it literally prints out these:
    How about DeLillo[.|?|!] [A-Z] still haven't read him[.|?|!] [A-Z]r Saul Bellow[.|?|!] [A-Z] told you I like Herzog a lot...maybe
    thanks for your help!
    -Won

    You don't want to add a space if there is already a second space. The following will turn any number of spaces after the sentence into two spaces. Note if the whitespaces include a \n\n (paragraph mark) it will turn everything into one long paragraph.
    replaceAll("([\\.\\?!])\\s+", "$1  ");

  • It's simple... I want the Illustrator pen tool to ALWAYS make corner annchor points and NEVER smooth.  Right now I have to convert every single one of them, or I have to do a work around every time I draw a line and make one of the handles disappear.  Is

    It's simple... I want the Illustrator pen tool to ALWAYS make corner annchor points and NEVER smooth.  Right now I have to convert every single one of them, or I have to do a work around every time I draw a line and make one of the handles disappear.  Is there some simple setting out there that will just "make it so?"@

    The video I am watching this guy is just dragging every line to make curves.  And every anchor point is a corner.  He is not switching back and forth between the pen and the anchor points tool, and he is not using the convert points tool.  He draws a curved line and starts another straight line only to curve it with a click and a drag.  It is super efficient, and I could save a world of time if I could figure out what he is doing.

  • Single and double quotes entered in form field cause corruption?

    I am creating a database change request system using in APEX 2.2 and the main form has a description field (clob) and a API_description field (varchar2(4000)) that are text area fields on the page. The form seems to have trouble when the string data entered into the text area page items on the form contain single and double quotes.
    <br><br>
    I have pasted my test data below in this problem description(this is not true sql but it gets the point accross). I use the wizard created insert process to get the data into the db from the text fields in the wizard generated form, then use the wizard created fetch process to get the data back out and rendered on the same form. When I use the test data below, sometimes a few characters dissappear from my input data on the way out, sometime form fields go away, and their html is interspersed with the previous form field's data on the page. And I get different results on different tests with the same data.
    <br><br>
    Do I have to do something special for a vanilla htmldb text page item on a form to be able to receive single and double quotes in the string input in order to avoid that string data confusing the processing on the way in to the Database or on the way out for rendering?
    <br><br>
    Do I have to escape the characters? How do I do this?
    <br><br>
    The "varchar2(1) := ‘A’" part of the below TEST DATA string seem to cause the most trouble. The behavior is erratic - sometimes the pattern works, sometimes html is interspersed in one place, sometimes another (on the way back out)
    <br><br>
    START TEST DATA:
    Add column pcl3_data_ind varchar2(1) to edc_tran,edc_log, edc_recreate_tran table
    Or
    Create a file with following sql in it
    Insert into sometable values(‘A’,sysdate);
    Or
    create new table as follows
    create table “someschema”.“sometable”
    (id number not null,
    Name varchar2(20) not null,
    Join_date sysdate
    Active varchar2(1) := ‘A’
    END TEST DATA:
    <br><br>
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Here is an example of the test data being displayed after being fetched back out of oracle (this will look like gibberish when rendered in the forum system (end of problem description except for example):
    <br><br>
    env
    Add column pcl3_data_ind varchar2(1) to edc_tran,edc_log, edc_recreate_tran table
    Or
    Create a file with following sql in it
    Insert into sometable values(‘A’,sysdate);
    Or
    crete new tableas follws
    crate table “somesca”.“sometable”
    har2(20) not null,
    Join_date sysdate
    Active varchar2(1) := ‘A’
    woextarea>
    <a class="eLink" title="Edit" href="javascript:popupURL('f?p=4000:371:204538675714370::::P371_ID,FB_FLOW_ID,FB_FLOW_PAGE_ID:1034609472735510,104,2');" tabindex="999"><img src="/i/e.gif" alt="Edit" class="eLink" /></a></td></tr><tr><td nowrap align="right"><label ...

    I found a good php related post that has a nice set of the potentially problematic characters (this is in the context of word pasted into IE I think). I am pretty confident that at least single curly quotes do not work well in apex 2.2). I would not be surprised if some of the others were trouble as well.:
    http://lists.evolt.org/archive/Week-of-Mon-20030602/141975.html
    here is the list
    $trans_tbl[chr(34)] = '"' ;          //      quote
              $trans_tbl[chr(38)] = '&' ;          //      ampersand
              $trans_tbl[chr(60)] = '<' ;          //      less-than
              $trans_tbl[chr(62)] = '>' ;          //      more-than
              $trans_tbl[chr(128)] = '€' ;     //      euro
              $trans_tbl[chr(129)] = '€' ;      //     euro
              $trans_tbl[chr(130)] = '‚' ;      //     low quote
              $trans_tbl[chr(131)] = 'ƒ' ;      //     florin
              $trans_tbl[chr(132)] = '„' ;      //      double low quote
              $trans_tbl[chr(133)] = '…' ;      //     ellipsis
              $trans_tbl[chr(134)] = '†' ;     //     dagger
              $trans_tbl[chr(135)] = '‡' ;      //     double dagger
              $trans_tbl[chr(136)] = 'ˆ' ;      //     circumflex
              $trans_tbl[chr(137)] = '‰' ;      //     per thousand
              $trans_tbl[chr(138)] = 'Š' ;      //     S caron
              $trans_tbl[chr(139)] = '‹' ;      //     left angle quote
              $trans_tbl[chr(140)] = 'Œ' ;      //     OE ligature
              $trans_tbl[chr(142)] = 'Ž' ;      //     Z caron
              $trans_tbl[chr(145)] = '‘' ;      //     left single quote
              $trans_tbl[chr(146)] = '’' ;      //     right single quote
              $trans_tbl[chr(147)] = '“' ;      //     left double quote
              $trans_tbl[chr(148)] = '”' ;      //     right double quote
              $trans_tbl[chr(149)] = '•' ;      //     bullet
              $trans_tbl[chr(150)] = '–' ;      //     en dash
              $trans_tbl[chr(151)] = '—' ;      //     em dash
              $trans_tbl[chr(152)] = '˜' ;      //     small tilde
              $trans_tbl[chr(153)] = '™' ;      //     trademark
              $trans_tbl[chr(154)] = 'š' ;      //     small s caron
              $trans_tbl[chr(155)] = '›' ;      //     right angle quote
              $trans_tbl[chr(156)] = 'œ' ;      //     oe ligature
              $trans_tbl[chr(158)] = 'ž' ;      //      small z caron
              $trans_tbl[chr(159)] = 'Ÿ' ;      //     Y with diaeresis
    <br>
    -Geoffrey

  • Convert 1 single microsoft word document with section breaks to multiple pdf files

    I am a windows 7 users. I have a single microsoft word document which contain 1500 pages. These 1500 pages are seperated by sections breaks in the microsoft word. I am trying to convert this word document to multiple pdf files seperated by the section breaks in the Microsoft word. How can I convert the single microsoft word document with section breaks to multiple seperate pdf files?

    Acrobat (Adobe PDF Printer and PDFMaker ) doesn't recognize the Section breaks.  It never has as far as I am aware.  The easiest thing to do is to manually break up a copy of the MS Word Document into the Sections you need and then create the PDFs from those MS Word documents.

  • MySQL will only let me use backticks (not single or double quotes)

    What the hell is going on here? This worked fine until a recent update.
    SELECT * FROM "table";
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"table"' at line 1
    SELECT * FROM 'table';
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''table'' at line 1
    SELECT * FROM `table`;
    (table prints normally here)
    12 rows in set (0.00 sec)
    The error happens both in the mysql client, phpmyadmin, and all my php scripts. How do I make it accept single and double quotes?
    Phpmyadmin has this to say about the mySQL installation
    Server: Localhost via UNIX socket
    Server version: 5.1.50
    Protocol version: 10
    User: root@localhost
    MySQL charset: UTF-8 Unicode (utf8)
    Last edited by Krause (2010-10-16 10:18:16)

    Hello
    In the SQL Standard, table and column names don't have to be between quotes, only values can be (for instance if you have spaces in a value).
    Just call "SELECT * FROM table;", that's all.

  • Convert from Single Org to Multi-Org

    Hi All,
    Can someone tell me what are the steps to convert from Single Org to Multi-Org ?
    Is it only the profile value 'MO: Operating Unit' to be setup ? or any other steps to be setup ?
    Regards
    Jhansi

    Jhansi,
    Please see the following:
    Note 259546.1 - Setting Up Multiple Organizations in Oracle HRMS
    Regards,
    Greg

  • Does anybody know any software for the Mac that I can run round robin, single and double elimination tournaments?

    Does anybody know any software for the Mac that I can run round robin, single and double elimination tournaments?  I help run tournaments but using excel for pool play and the web for bracket play, but if wifi is not available I have no way of running brackets for prize play.  Can some one help point me in the direction of software that I can use locally on my Mac Pro. 
    Thanks,
    Chris
    <E-mail Edited by Host>

    Splendid City Team Sports Scheduler, and Sports Scheduling Software System

  • Programming button for single and double click

    I know how to programme a button to play a certain movie segment. However, in my current project I need to be able to programme a button in the menu so that
    1. on rollover - nothing
    2. on single mouse click - button colour changes + a parapraph of text appears on the menu screen in a predefined space
    3. on double click - a movie clip plays
    It might be a simple qiestion but I would greatly appreciate it if you could point me in the right direction.
    Thanks.

    Nick76 wrote:
    I know how to programme a button to play a certain movie segment. However, in my current project I need to be able to programme a button in the menu so that
    1. on rollover - nothing
    Do not change the highligh and it will look like nothing is happening (make sure auto activate is not beign used)
    2. on single mouse click - button colour changes + a parapraph of text appears on the menu screen in a predefined space
    3. on double click - a movie clip plays
    It might be a simple qiestion but I would greatly appreciate it if you could point me in the right direction.
    Thanks.
    Single and Double clicks cannot be done like that. (Some players using layered menus do require a click to get things seen but not really what you are speaking about.)
    Flash or Director may be better for this?

  • URGENT!! CELLWRAPPER single and double quot issues???

    REP-50003: Bad parameter:  CELLWRAPPER='I get this error whenever I try and use single or double quotes as a cellwrapper.
    However if I do [SPACE][SPACE] as a cell wrapper this works fine?Is this a bug? I'm sure we have version "10.1.2.0.2"?

    It does appear to be a bug. Look here on Metalink for details.

  • Convert domains Single values

    Hi!
    I'm trying to convert domains Single values (fromvalue range) into another languages. .
    Thx
    ilhan

    What is your db version?
    In 11g you can do
    SQL> var str varchar2(30)
    SQL> exec :str := 'SCOTT,KING,JONES,ALLEN'
    PL/SQL procedure successfully completed.
    SQL> select empno, ename from emp, xmltable(('"' || replace(:str, ',', '","') || '"'))
    where ename = trim(column_value)
         EMPNO ENAME    
          7788 SCOTT    
          7839 KING     
          7566 JONES    
          7499 ALLEN    
    4 rows selected.

Maybe you are looking for

  • No SIM card error

    I'm getting a no SIM card error. When I got a new SIM card it now says no service! My cell provider assures me it's not on their end, which makes sense as we have 2 more iPhones on the same account! Any ideas?

  • Data Guard Broker - Complete/Immediate Failover ???

    Dear Experts, I have been reading about Data Guard Broker from Oracle Doc's (10.2). I came across two terms: Immediate Failover and Complete Failover. I understood from the doc's what each one of them does but unable to understand how to trigger them

  • Did not backup iphone6 before synching with old iphone4. Can i retrieve photos I took with iphone6?

    I've used my new iphone6 and didn't backup before I uploaded details from my old iphone4. Now I've lost all photos etc from my iphone6. Is it possible to get those photos back?

  • I can't log in to my GoPhone account to refill my balance

    I repeatedly tried to log in to my GoPhone account starting at about 11:45pm 7/27/15 and kept getting a 'This webpage is not available' message. I also dialed 611 and your 800 number from my phone, entered my phone number, and was told there was no a

  • X31 Disapear at Start-up IMB Thinkpad Logo

    hello, My IMB Thinkpad X31 got problem below: When i press power botton, it stopped me at start-up IMB Thinkpad Logo. Please help me to get it works. Thanks and sorry for my bad english.