1&|  works perfectly
 

    Den 9:19 søndag den 6. august 2017 skrev Martin Kreuzer 
<i...@airkreuzer.com>:
 

 In easy steps (and for further reference) ...

 From these test data (two floats, two integers, different signs), to 
get the fractional parts

    v=. 2.25 _8.11 16 _3

simply taking the Residue (when dividing by 1) doesn't work (error at 
negative float position)

    1|v
0.25 0.89 0 0

So first get Magnitude

    | v
2.25 8.11 16 3

then take Residue

    1 | (| v)
0.25 0.11 0 0

then get the sign right (see Raul's remark below)

    (*v) * (1 | | v)
0.25 _0.11 0 0

and put it as verb (fp), written as a fork

    fp=. * * 1||
    fp v
0.25 _0.11 0 0

-M

At 2017-08-06 02:14, you wrote:

>Eh... but that's wrong.  You can't add any integer to 0.542857 to 
>get _0.542857.
>
>If you want signed fractions, you'd need something like (*@] * (| |))
>
>Thanks,
>
>--
>Raul
>
>
>On Sat, Aug 5, 2017 at 10:01 PM, 'Pascal Jasmin' via Programming
><programm...@jsoftware.com> wrote:
> > combining other answers we get the cute:
>
> > 1 (| |)  _0.542857 _1.1875 1.96552 2.92308 4.13043 5.7 7.82353 
> 10.8571 15.5455 23.75
>
>
>
>
> > ________________________________
> > From: Bill <bbill....@gmail.com>
> > To: "programm...@jsoftware.com" <programm...@jsoftware.com>
> > Sent: Saturday, August 5, 2017 8:30 PM
> > Subject: Re: [Jprogramming] Fractional parts
>
>
>
> > this also depends on what do you expect for negative numbers.
>
> > Sent from my iPhone
>
> > On 6 Aug, 2017, at 7:35 AM, Skip Cave <s...@caveconsulting.com> wrote:
>
> >> Oops! i meant:
> >>
> >> How does one find the fractional parts of a vector of floating point
> >> numbers?
> >>
> >> 0.542857 1.1875 1.96552 2.92308 4.13043 5.7 7.82353 10.8571 15.5455 23.75
> >> 41.8 114 247
> >>
> >> i want:
> >> 0.542857 0.1875 0.96552 0.92308 0.13043 0.7 0.82353 0.8571 5.5455 0.75 0.8
> >> 0 0
> >>
> >> (Last two integers have zero fractional part.)
> >>
> >>
> >> Skip Cave
> >> Cave Consulting LLC
> >>
> >> On Sat, Aug 5, 2017 at 6:30 PM, Skip Cave <s...@caveconsulting.com> wrote:
> >>
> >>> How does one find the fractional parts of a vector of floating point
> >>> numbers?
> >>>
> >>> 0.542857 1.1875 1.96552 2.92308 4.13043 5.7 7.82353 10.8571 15.5455 23.75
> >>> 41.8 114 247
> >>>
> >>> i want:
> >>> 0.542857 0.1875 0.96552 0.92308 0.13043 0.7 0.82353 0.8571 
> 5.5455 0.75 0.8
> >>> 114 247
> >>>
> >>> Skip
> >>>
> >>> Skip Cave
> >>> Cave Consulting LLC
> >> ----------------------------------------------------------------------
> >> For information about J forums see http://www.jsoftware.com/forums.htm
>
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
>----------------------------------------------------------------------
>For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

   
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to