[Gambas-user] R: ieee754

Ru Vuott vuott at ...325...
Fri Dec 27 17:08:38 CET 2013


ello Jussi,

> Seek #hStr, 0
> 
>   f = Read #hStr As Single

I didn't set "Seek" in my suggestion, because I thought the reading started from zero "by default".


bye
vuott





--------------------------------------------
Ven 27/12/13, Jussi Lahtinen <jussi.lahtinen at ...626...> ha scritto:

 Oggetto: Re: [Gambas-user] R: ieee754
 A: "mailing list for gambas users" <gambas-user at lists.sourceforge.net>
 Data: Venerdì 27 dicembre 2013, 14:56
 
   Dim i As Integer
   Dim f As Single
   Dim p As Pointer
   Dim hStr As Stream
 
     i = &h3EAAAAAA&
 
     p = Alloc(SizeOf(gb.Integer))
 
     hStr = Memory p For Read Write
 
     Write #hStr, i As Integer
 
     Seek #hStr, 0
 
     f = Read #hStr As Single
 
     Print f
 
     Free(p)
     Close #hStr
 
 
 Seek is needed for the automatically increasing internal
 pointer.
 http://gambasdoc.org/help/lang/memory?v3&en
 
 
 Jussi
 
 
 
 On Fri, Dec 27, 2013 at 2:09 PM, wally <wally at ...2037...>
 wrote:
 
 > Thank You !
 >
 > but result is "1.261169E-44"
 >
 > expected "3.33333E-1"
 > 3.33333313465118408203125E-1
 >
 >
 > On Friday 27 December 2013 11:31:10 Ru Vuott wrote:
 > > Using Memory Stream:
 > >
 > > Public Sub Main()
 > >
 > > ' i = &h3EAAAAAA& 'IEEE representation of
 1/3
 > >
 > > Dim i As Integer
 > > Dim x As Single
 > > Dim p As Pointer
 > > Dim s As Stream
 > >
 > >     i = &h3EAAAAAA&
 > >
 > >
 > >     p = Alloc(4)
 > >
 > >     s = Memory p For Write
 > >
 > >     Write #s, i As Integer
 > >     Read #s, x
 > >     Print x
 > >     Free(p)
 > >
 > > End
 > >
 > >
 > >
 > > --------------------------------------------
 > > Ven 27/12/13, wally <wally at ...2037...>
 ha scritto:
 > >
 > >  Oggetto: [Gambas-user] ieee754
 > >  A: "mailing list for gambas users" <gambas-user at ...66...et>
 > >  Data: Venerdì 27 dicembre 2013, 10:57
 > >
 > >  Hi,
 > >
 > >  i need to convert 4byte and 8byte HEX to
 single and float.
 > >  The following code works on gambas2 but
 seems to need
 > >  modifications in Gambas3.
 > >  Any working example for Gambas3 available ?
 > >
 > >  Public Sub Button3_Click()
 > >  ' i = &h3EAAAAAA& 'IEEE
 representation of 1/3
 > >
 > >  Dim i As Integer
 > >  Dim x As Single
 > >  Dim p As Pointer
 > >
 > >      i = &h3EAAAAAA&
 > >
 > >      p = Alloc(4)
 > >      Write #p, i, 4
 > >      ' << error *
 > >      Read #p, x
 > >      Free(p)
 > >     Print x
 > >
 > >  End
 > >
 > >
 > >  *  "Type mismatch: wanted Stream, got
 Pointer instead"
 > >
 > >  thx wally
 > >
 > >
 > >
 > 
 ---------------------------------------------------------------------------
 > > --- Rapidly troubleshoot problems before they
 affect your
 > >  business. Most IT
 > >  organizations don't have a clear picture of
 how application
 > >  performance
 > >  affects their revenue. With AppDynamics, you
 get 100%
 > >  visibility into your
 > >  Java,.NET, & PHP application. Start your
 15-day FREE
 > >  TRIAL of AppDynamics Pro!
 > >
 > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
 > > _______________________________________________
 > >  Gambas-user mailing list
 > >  Gambas-user at lists.sourceforge.net
 > >  https://lists.sourceforge.net/lists/listinfo/gambas-user
 > >
 > >
 > >
 >
 ----------------------------------------------------------------------------
 > > -- Rapidly troubleshoot problems before they
 affect your business. Most
 > IT
 > > organizations don't have a clear picture of how
 application performance
 > > affects their revenue. With AppDynamics, you get
 100% visibility into
 > your
 > > Java,.NET, & PHP application. Start your
 15-day FREE TRIAL of AppDynamics
 > > Pro!
 > >
 > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
 > > _______________________________________________
 > > Gambas-user mailing list
 > > Gambas-user at lists.sourceforge.net
 > > https://lists.sourceforge.net/lists/listinfo/gambas-user
 >
 >
 >
 ------------------------------------------------------------------------------
 > Rapidly troubleshoot problems before they affect your
 business. Most IT
 > organizations don't have a clear picture of how
 application performance
 > affects their revenue. With AppDynamics, you get 100%
 visibility into your
 > Java,.NET, & PHP application. Start your 15-day
 FREE TRIAL of AppDynamics
 > Pro!
 > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
 > _______________________________________________
 > Gambas-user mailing list
 > Gambas-user at lists.sourceforge.net
 > https://lists.sourceforge.net/lists/listinfo/gambas-user
 >
 ------------------------------------------------------------------------------
 Rapidly troubleshoot problems before they affect your
 business. Most IT 
 organizations don't have a clear picture of how application
 performance 
 affects their revenue. With AppDynamics, you get 100%
 visibility into your 
 Java,.NET, & PHP application. Start your 15-day FREE
 TRIAL of AppDynamics Pro!
 http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
 _______________________________________________
 Gambas-user mailing list
 Gambas-user at lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user





More information about the User mailing list