|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Unsigned C long to signed VB5 Long query.I've been searching high and low for the right solution to what should
be something simple and instead of the what I have read as 'If you pass an unsigned value greater than 2,147,483,647 to a LONG variable, the value will be interperted as a negarive number.' instead I get the 'value overflow' result. What is the correct method for getting an unsigned LONG value into a VB Signed LONG? Many thanks. Hi Richard,
Long in VB is 32 bits, as is LONG in C. If you are merely representing the value use the bitwise value. How the high order bit is interpreted only matter when you are converting the value out of the storage type or doing manipulation on it. For example, if the C value is 0x80000001 then the VB long value is &H80000001 in terms of bits. So typically you can ignore the fact the sign bit has special meaning, unless you are converting values such as double to string to Long, or you are trying to do maths on them etc. Oh, and when using bitwise values, always use And, Or, XOr and Not; not numeric operators. Show quoteHide quote "Richard Brooks" <richardbro***@vickers-armstrongs.com> wrote in message news:3_udncnD-J9GWjzUnZ2dnUVZ8s_inZ2d@bt.com... > I've been searching high and low for the right solution to what should be > something simple and instead of the what I have read as 'If you pass an > unsigned value greater than 2,147,483,647 to a LONG variable, the value > will be interperted as a negarive number.' instead I get the 'value > overflow' result. > > What is the correct method for getting an unsigned LONG value into a VB > Signed LONG? > > > Many thanks. "Richard Brooks" <richardbro***@vickers-armstrongs.com> wrote Well the trick there is, where are you getting the unsigned long?> I've been searching high and low for the right solution to what should > be something simple and instead of the what I have read as 'If you > pass an unsigned value greater than 2,147,483,647 to a LONG variable, > the value will be interperted as a negarive number.' instead I get the > 'value overflow' result. > > What is the correct method for getting an unsigned LONG value into a > VB Signed LONG? You can assign any supported value you want using hexidecimal notation: Z = &HFFFFFFFF LFS Larry Serflaten said the following on 23/02/2009 00:29:
Show quoteHide quote > "Richard Brooks" <richardbro***@vickers-armstrongs.com> wrote Thanks for the reply (and to Bill McCarthy in other post).>> I've been searching high and low for the right solution to what should >> be something simple and instead of the what I have read as 'If you >> pass an unsigned value greater than 2,147,483,647 to a LONG variable, >> the value will be interperted as a negarive number.' instead I get the >> 'value overflow' result. >> >> What is the correct method for getting an unsigned LONG value into a >> VB Signed LONG? > > Well the trick there is, where are you getting the unsigned long? > > You can assign any supported value you want using hexidecimal > notation: > > Z = &HFFFFFFFF > > LFS My task is to read in aircraft position data from a file built by a flight data recorder, FS recorder programmed by Matthias Neusinger who has kindly sent me the subroutines and data formats which is programmed in C which IIRC writes in Low Byte Order First, so in a four byte data block, the right-hand most byte block is the High Byte value. I think the problem is now sorted as I was converting and multiplying each byte then adding that subtotal value to a Long variable but now, just building the byte block and converting it at the end works. A very many thanks to you both. Hi Richard,
Show quoteHide quote "Richard Brooks" <richardbro***@vickers-armstrongs.com> wrote in message You're welcome. Glad you got it sorted outnews:_c-dndGfKc9whj_UnZ2dnUVZ8h2dnZ2d@bt.com... > Larry Serflaten said the following on 23/02/2009 00:29: >> "Richard Brooks" <richardbro***@vickers-armstrongs.com> wrote >>> I've been searching high and low for the right solution to what should >>> be something simple and instead of the what I have read as 'If you >>> pass an unsigned value greater than 2,147,483,647 to a LONG variable, >>> the value will be interperted as a negarive number.' instead I get the >>> 'value overflow' result. >>> >>> What is the correct method for getting an unsigned LONG value into a >>> VB Signed LONG? >> >> Well the trick there is, where are you getting the unsigned long? >> >> You can assign any supported value you want using hexidecimal >> notation: >> >> Z = &HFFFFFFFF >> >> LFS > > Thanks for the reply (and to Bill McCarthy in other post). > > My task is to read in aircraft position data from a file built by a flight > data recorder, FS recorder programmed by Matthias Neusinger who has kindly > sent me the subroutines and data formats which is programmed in C which > IIRC writes in Low Byte Order First, so in a four byte data block, the > right-hand most byte block is the High Byte value. > > I think the problem is now sorted as I was converting and multiplying each > byte then adding that subtotal value to a Long variable but now, just > building the byte block and converting it at the end works. > > A very many thanks to you both. .. Bill McCarthy wrote:
> You're welcome. Anyone taking notes for the next edition of, "The Complete Idiot's Guide to Gratuitous Post Count Inflation"? "Karl E. Peterson" <k***@mvps.org> skrev i meddelandet Sorry, but I'm getting an overflow the index in the Decimal data type ;)news:OYzb50elJHA.1288@TK2MSFTNGP02.phx.gbl... > Bill McCarthy wrote: >> You're welcome. > > Anyone taking notes for the next edition of, "The Complete Idiot's Guide > to Gratuitous Post Count Inflation"? > -- > .NET: It's About Trust! > http://vfred.mvps.org > /Henning Henning wrote:
> "Karl E. Peterson" <k***@mvps.org> skrev ... Yeah, that's a very real danger when you *ignore* the terminal condition check!>> Bill McCarthy wrote: >>> You're welcome. >> >> Anyone taking notes for the next edition of, "The Complete Idiot's Guide >> to Gratuitous Post Count Inflation"? > > Sorry, but I'm getting an overflow the index in the Decimal data type ;)
optional args to a class.Init method
Anyway to move Image control at runtime Dim WithEvents * As HTMLDocument with an Iframe - access denied!? Recommended IDE for the PocketPC Automatic determine .Rows in MSHFLexgrid Cannot pass a control array ? Remove empty elements from end of array Use ColumnClick and Click Event in MSHFLexGrid convert Unicode string RGB to CIELAB (or simply lab) color conversion |
|||||||||||||||||||||||