I guess you're reading data from a file, since Perl 6 numbers (such as 11.01) might have a Rat representation. If so I guess you have that data in a Blob, then read the four bytes using read-uint8 (https://docs.perl6.org/routine/read-uint8) and apply .base(2) to each of them.
On Tue, Sep 3, 2019 at 2:30 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 9/3/19 5:21 AM, ToddAndMargo via perl6-users wrote: > >>> On Tue, Sep 3, 2019 at 1:15 PM ToddAndMargo via perl6-users > >>> <perl6-us...@perl.org <mailto:perl6-us...@perl.org>> wrote: > >>> > >>> Hi All, > >>> > >>> How would I print out what a 32 real value of > >>> 11.01 (base 10) looks like in its raw > >>> binary form (ones and zeros)? > >>> > >>> Many thanks, > >>> -T > > > > On 9/3/19 5:09 AM, Fernando Santagata wrote: > >> Is this what you need? > >> > >> > (11.01).base(2) > >> 1011.00000011 > >> > >> -- > >> Fernando Santagata > > > > > > > > Perfect! Thank you! > > > > $ p6 'say (11.01).base(2)' > > 1011.00000011 > > > > How would I do it in reverse. Give a base 2 number > > and print it in base 10? > > > > Wait a minute. There is no decimal point. Only ones and zeros. > I am looking for a binary dump of what a 32 bit real variable > actually contains. > -- Fernando Santagata