Integer and fractional part of the number

Hello everybody,
I want to divide the floating point number to 2 integer words, first will receive the interger part of number, and the second will receive the fractional part of the number.
For example: I have number 751.98 in DBL, then I create two integer fields: first has value 751, second has value 98.
I have tried simple conversion from DBL to I16, but it always rounded me to higher interger. I don't want to round it. And I just don't know how to transform the fractional part to integer. Are there any specialized functions for this? Maybe should I use log10 or similar?
TIA,
Jacek.

The place to start with this problem is the IEEE-754 numerical
representations:
32 bit floating point is internally:
highest order bit is the sign bit.
the next 8 bits are the exponent bits
the last 23 bits are the mantissa bits
the mantissas and exponents are binary.
the mantissa value in a 1.22 fixed point binary number, i.e. the most
significant binary bit is equal to 1, the next most is equal to 1/2,
the next most is equal to 1/4, etc., etc.
The exponent part can go between 2^-127 and 2^128
You should be able to cast your 32 bit float to a 32 bit unsigned
integer, separate it into sign, mantissa and exponent parts, use the
exponent to rotate left or right your mantissa decimal point by the
exponent value and then separate the whole part from the fractional
part and then put each into the I16's or U16's as you want.
Douglas De Clue
LabVIEW programmer
[email protected]
[email protected] (Michael Ross) wrote in message news:...
> This problem needs some limits. Like: only return the decimal portion
> out to 6 places.
>
> First run the number through Remainder and Quotient (divisor of 1).
>
> 751.98743674645641000000 gets remainder of
>
> 0.98743674645641021900
>
> "floor" is 751
>
> Take the remainder and send through Decimal to Fractional String (this
> is where you set your number of decimal places [default is 6]).
>
> returns 0.987437
>
> Then use String Subset and set it to an offset of 2 (cleans off the
> leading zero and decimal point) with the "length" input left at the
> default of "rest" (of string).
>
> 987437 (in string form)
>
> Now use String to Decimal Number
>
> returns 987437 (as a decimal number)
> ====================================
> I think if you don't limit the number of places it is ugly. It is
> ugly going from numbers to strings and then back. But all numbers is a
> bad thing.
>
> The alogirithm for finding the answer mathematically is nasty.
> Especially without a limit on decimal places. You have to figure out
> the number of decimal places and multiply by the inverse of the last
> decimal place. Sounds easy.
> =============================
> Try this: New number: 751.98652
>
> Truncate out the remainder (Remainder and Quotient (divisor of 1)):
>
> 751.98652 ---> 0.98652
>
> Mult by 10 ----> 9.8652
>
> Take the floor (9) and divide by 10 ----> 0.9
>
> subtract the new number from the old. Is the answer non-zero? Not,
> then keep on
>
> 0.98652 - 0.9 = .08652 which not equal to 0
>
> If it is zero, the floor is the answer.
>
> Continue - Not:
>
> This time multiply by 100 ----> 98.652
>
> floor is 98, divide by 100 ----> 0.98
>
> Subtract 0.98 from 0.98652 = .00652 still non zero.
>
> Keep on. 1,000, 10,000...When you get to 100,000
>
> 0.98652 x 100,000 = 98652.00
>
> Get the floor
>
> divide the floor by 100,000 to get the original number (remainder is
> now 0.000), compare to original remainder
>
> 0.98652 - 0.98652 = 0. Yay.
>
> Take the 98652 and go with it. The last place was the one hundred
> thousandth.
>
> I can't take credit for the last, I had uglier stuff going on. I did
> do the string thing.
>
> I swear this is just like some sorry homework problem.
>
> Mike

Similar Messages

  • How to obtain the integer and fractional parts of a number ?

    Good morning,
    given the value:
    5433.43567
    I'd like to know if there is a function such that
    f(5433.43567) = 5433
    and another such that
    f2(5433.43567) = 0.43567Without any rounding, truncation or other "special effects" ;). I can synthesize those functions using to_char, string manipulation and to_number but I'd like to make sure that I didn't miss a simpler way or, a combination of those functions that is really simple (the stuff I've come up with is hardly simple :( )
    Thank you for your help,
    John.

    440bx - 11gR2 wrote:
    Good morning BluShadow, Afternoon! :)
    select regexp_substr(.43567, '[^.]+', 1, 1) as whole_part
    ,regexp_replace(5433, '[^.]+\.(.*)$', '0.\1') as fract_part
    from dual;
    The result should be 0 (or blank).
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 5433.43567 as num from dual union all
      2             select 0.43567 from dual union all
      3             select 5433 from dual)
      4  select num
      5        ,regexp_substr(num, '^[^.]+') as whole_part_string
      6        ,regexp_substr(num, '\.[^.]+$') as fract_part_string
      7        ,trunc(num) as whole_part_number
      8        ,num-trunc(num) as fract_part_number
      9* from t
    SQL> /
           NUM WHOLE_PART_STRING                        FRACT_PART_STRING                        WHOLE_PART_NUMBER FRACT_PART_NUMBER
    5433.43567 5433                                     .43567                                             5433               .43567
        .43567                                          .43567                                                0               .43567
          5433 5433                                                                                        5433                    0
    SQL>Personally, I'd just stick with the number variants using trunc. Far simpler to use and you're still dealing with numbers.

  • How can I activate an old version of Photoshop that I've loaded on my new tablet? The web activation doesn't work, and when I call the number, it says it's not being used anymore. Meanwhile, I'm down to 13 days till it stops working due to not being activ

    How can I activate an old version of Photoshop that I've loaded on my new tablet? The web activation doesn't work, and when I call the number, it says it's not being used anymore. Meanwhile, I'm down to 13 days till it stops working due to not being activated. HELP?  I really need to continue using this product for my home business.It works fine not activated but the threat is that it will stop working in 13 more days if I don't get it activated, and none of the activation methods they list seem to work.

    The new serial number is to the right of your chosen download.

  • Is there another way to close apps other than deleting them from the multitask bar.....I have a small crack in the bottom of my screen and that part of the screen does not recognize the touch.  :(

    Is there another way to close apps other than deleting them from the multitask bar.....I have a small crack in the bottom of my screen and that part of the screen does not recognize the touch. 

    There's generally no reason to be closing them that way at all. The apps you see in the recents bar are just that, apps that you used recently. Most of them are doing absolutely nothing. The only apps that are really doing anything in the background are ones that play music and ones that are using location services. Just leave them be.
    Best of luck.

  • Before, when reading PDF files, I was able to copy and paste part of the book. Now it is not possible. I can copy but when pasting gets nothing.  Antes, quando lia arquivos PDF, eu conseguia copiar e colar parte do livro. Agora isso não é possível.

    Before, when reading PDF files, I was able to copy and paste part of the book. Now it is not possible. I can copy but when pasting gets nothing.
    Antes, quando lia arquivos PDF, eu conseguia copiar e colar parte do livro. Agora isso não é possível. Eu consigo copiar, mas quando vou colar o texto, não cola nada.

    Caro Fabiano,
    Obrigado por ter contactado as Comunidades de Suporte Apple.
    Na origem do seu problema podem estar várias causas. Nomeadamente:
    O ficheiro (arquivo) que está a ler pode não ser texto, ou seja, pode ser texto transformado em imagem e exportado como PDF.
    A aplicação de destino (onde está a tentar colar o texto copiado) pode não aceitar a colagem de texto formatado.
    A aplicação que está a utilizar para abrir os ficheiros PDF pode não ser indicada para certo tipo de documentos. Experimente o iBooks, o Dropbox ou até mesmo o seu e-mail.
    No caso de nenhuma destas causas estar na origem do seu problema, forneça, por favor, mais informações sobre a origem do ficheiro (descarga pelo Safari, Mail ou outro) bem como o destino (documento Pages, Keynote ou Numbers ou outra aplicação que não o iWork).
    Atentamente,
    Gonçalo Matos
    Estou aqui para ajudar. Clique no botão "Reply" no caso de ter outra questão ou necessitar de outro esclarecimento para que eu possa ajudar da melhor forma que conseguir.

  • In the new iOS-7 Safari, has the "reader" function been changed to eliminate the option to modify font size (and hence to modify the number of words per line), or is it just that I can't find how to do that?

    In the new iOS-7 Safari, has the "reader" function been changed to eliminate the option to modify font size (and hence to modify the number of words per line), or is it just that I can't find how to do that?

    iOS 7
    Seperate text size modification is no longer available in Safari Reafer.
    Use Settings.
    Settings >General > Text Size

  • I Took apart a mac mini 2007 and i cant put it back together and a part holding the cmos battery broke off

    I Took apart a mac mini 2007 and i cant put it back together and a part holding the cmos battery broke offplease i need serius help

    Yikes, see if anything here helps...
    http://www.ifixit.com/Teardown/Mac-mini-Model-A1283-Teardown/659/1
    And on yhe battery clip, do you suppose Super  Glue would work?

  • My iPhone does not tell me Who is calling Many times and ofer me only the number. what can I do to see the owners of the number?

    My iPhone doesn't tell me Who is calling several times and only gives me the number. What can I do to see the owners names?

    if you have verizon as your provider
    Dial *228 from your iPhone.
    When prompted, select option 1.
    When complete, you will hear a confirmation message.
    Force the Contacts, Messages, and Phone applications to close using the following steps:
    Ensure that you have recently opened the Contacts, Messages, and Phone applications.
    From the Home screen, double-click the Home button to display the recently used apps.
    Tap and hold the icon for the Contacts application until a red minus appears.
    Tap the red minus to close the app.
    Repeat the previous step for the Messages and Phone applications.
    Tap the Home screen to return.
    Turn iPhone off and then back on

  • How to adjust the green (starting) and the red (end) rectangles pixel by pixel (top, bottom, left and right) by changing the number of pixels in ken burns.

    How to adjust the green (starting) and the red (end) rectangles pixel by pixel (top, bottom, left and right) by changing the number of pixels in ken burns. Help please.

    If you look closely at the top of the canvas pane, as you move either of the boxes (green or red) there is an indication of pixel positions... "top, bottom, left, right," and "scale."
    Admittedly, it doesn't seem as if you can "enter" the dimensions with your keyboard, however, as you move the boxes, you have a real time indication of the boxs' locations.
    (I couldn't take a screen shot, as you have to actively move the box with a mouse or other input device... thus, I could not also take a screen shot with same device.)
    I hope this helps.

  • Is there a way to cycle a while loop on its own and only controlled by the number of cycles?

    Hello everyone, 
    Newcomer here, recenlty just took core 1 and 2 the past couple of months
    is there a way to cycle my while loop so that the daq assist receives the same outputs from the list box table? So pretty much I need the VI to be able to read the voltages and time values from the list box and then execute them, I've manage to do this, but then I need it to stop for a given time and then execute again the same voltages. This would be controlled by a control for "number of cycles" input. 
    Can someone tell me why my "Emergency Stop" button doesn't stop the VI?
    Why is my data logging only outputing one result if I have it to read ever min?
    My wave form graph isnt plotting the temperature results, does it have somthing to do with the while loop?
    I know this is a lot of questions, I'm just trying to solve this and learn from it.
    Attachments:
    TEST RIG 11 10-28-13.vi ‏298 KB

    You took core 1 and 2!!!  Please tell me NI didn't teach it.  I'm not trying to harp on you too bad because I think the instructor is more to blame.  You have many wires going the wrong direction, multple loops doing nothing, and one loop that will never stop so even if all the others did there would be no way to stop your program, a Stop button that is read only once at the start of the application and then is never read again (so stop will never work).  You have the inner loop running forever, but even if it did stop it would run the outer loop forever, your enums should be typedefed, uninitialized shift registers when not needed, dynamic data types, far too many express VIs...ouch.
    To answer your question.  If you have a while loop that needs to run 5 times, why not use a for loop? Then wire a 5 to the N terminal.  If you do have to use a while loop for what ever reason, use the i terminal as a condition to stop.  It will start at 0 and count up so a value of 4 means it will be executing the 5 time.  If the value equals 5 then stop.  Get the Array size of the Listbox and set your for loop to run for each item.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • How can i put one part in front and one part in the back?

    Alright i made this phone and a person and i want to put the bottom in front of his chin and the top behind the ear. How should i do this? Couldnt find anything in my classroom in a book, book.
    thanks

    The part in front and the part in back have to be two separate objects. Put a rectangle to completely cover the bottom part of the phone and let it mask the whole phone. Copy the clipping group (or duplicate its layer in the layers panel); on the copy, direct-select the end of the mask rectangle that doesn't bisect the phone and drag it the other way, so the rectangle now covers (and crops) the top half of the phone. If you do this on layers you need only make sure the phone-bottom is on the top layer, phone-top is on the bottom layer, and the person layer is between them.

  • Just repaired cracked iPhone 4 screen and now part of the screen isn't working.

    A few days ago, I cracked my iPhone 4's screen pretty badly. I was having absolutely no trouble with the screen after I cracked it, aside from the crack, of course. I just got the screen repaired yesterday and now the bottom left part of the screen sometimes doesn't work. When I'm using the keypad, the following characters are affected:
    RDFCX (and sometimes E) 4 ; , } ~
    Also, sometimes, when I press that part of the screen, it's as if the phone doesn't recognize my touch. This is affecting scrolling, the ability to move the cursor, and makes it hard for me to unlock my phone because sometimes the bar along the bottom won't slide. However, when I select apps using that portion of the screen on the home screen, it works just fine.
    This started yesterday, about 2 hours after I got my screen fixed, then went away on its own a few hours later, and came back this morning.
    Does anyone know what this problem is/ what I should do about it? I'm definitely going to go back into the store that fixed my phone and see if they can correct it.
    **I did not get my phone fixed at the Apple store, I went to a store called BuyNCell which specializes in repairs of Apple and Blackberry products. I got my screen repaired as well as changed the casing on my phone to white.
    Hopefully someone can help explain to me what's going on. Thank you!!
    If it really matters, here's what my phone looked like before it was repaired. Yikes!

    This may sound crazy, but download any free app.  This often "shocks" the other apps into working.

  • I have an array here numbers are coming continuously, I have to make a table of number and repeition (frequency) of the number

    I have an array here numbers are coming continuously, I have to make a table of number and repeition (frequency) of the number

    So?  It is not clear what exactly you want to do.  Nor is it clear what problems you are having (other than asking us to do your work for you).  Why don't you try to solve this problem yourself, and if you get stuck, show us your code, tell us what questions you have, and someone will surely help you.
    BS

  • When i use arabic font with the build from the inspector the lower and uper part of the word is gone  ??

    my keynote 09 version 5.3
    i am using the arabic font albayan the problem is that when i use the build tool in the inspector the uper and the lower part of the word is gone i tryed to make the font smaller or adjust the position and that did not change so is there any way to fix this please because we can not use the build and the inspector tool like that ???!!!!!

    All iWork apps have bugs like this that make them generally unsuitable for RTL scripts like Arabic.  All you can do is try a different font and see if the results are any better.  Or try another app like OpenOffice or PowerPoint.
    Let Apple know this needs to be fixed via
    http://www.apple.com/feedback

  • When I select a local phone number my iphone 4 tries to send an email only and won't ring the number. Does anyone know if this can be fixed with a setting change?

    When I select a local phone number from my contacts, the iphone 4 won't ring the number, instead it tries to send an email. Does anyone know if this can be fixed with a setting change?

    Thanks for the reply, good try, I thought of that myself and made sure of that this morning, but that is already all done, and as it happens, the contacts are exactly the same as in our other phone (3GS) which works perfectly, but the iphone 4 won't dial ANY local number, instead it tries to send an email. EVERY TIME. most frustrating. I am really trying to work out if there is a setting somewhere (like the area code etc) or if this is a warranty issue.
    Thanks again for trying to help!

Maybe you are looking for

  • Can I add my AOL contacts to Address Book?

    Need some help getting AOL contacts into Address book, even or Mail for that matter. Thanks

  • Apache - mod_oc4j in 10.1.3 AS error connections

    We are experiencing a lot of [Thu Apr 17 12:33:23 2008] [warn] [client xxxxxx] oc4j_socket_recvfull timed out [Thu Apr 17 12:33:23 2008] [warn] [client xxxxxx] oc4j_socket_recvfull timed out [Thu Apr 17 12:33:23 2008] [error] [client xxxxxx] [ecid: 1

  • One way SMS + OTP in Azure MFA server

    Hi, how can i enable one way SMS in Azure MFA on premise? I have Azure MFA server and local active diretcory. I want users to receive a OTP and enter it to the logon page instead of replying to it? how can this be done? and if it is via the SDK, any

  • Can't back up iphoto -  error 36

    Trying to back up my iphoto library to an external hard drive. About halfway through I get an error message telling me one of the images can't be accessed, error 36. I applied Terrence Devlin's advice found in this thread: http://discussions.apple.co

  • I am unable to download voice over kit.

    Respected sir/ mam, I have used itunes to sync ipod shuffle before and it worked properly but now i re-installed itunes and im unable to download voice over kit, my internet is working finely. it says "the ipod software update server can not be conta