Git Product home page Git Product logo

Comments (7)

shanzhashu avatar shanzhashu commented on August 15, 2024

You can use
function DataToHex(InData: Pointer; ByteLength: Integer; UseUpperCase: Boolean = True): string;
in CnNative.pas to directly convert the memory content of Float number to a hex string.

given

var
A: Single;
begin
Caption := DataToHex(@A, SizeOf(A));
end;

from cnvcl.

sxbug avatar sxbug commented on August 15, 2024

thanksthanks

from cnvcl.

sxbug avatar sxbug commented on August 15, 2024

I only found the function: #1#2#3#4 <---> '1234'.
But I want a function:12.5 <---> '41 48 00 00'

Thanks

from cnvcl.

shanzhashu avatar shanzhashu commented on August 15, 2024

Could you use my code piece and check the result?

var
A: Single;
begin
A := 12.5;
Result := DataToHex(@A, SizeOf(A));
end;

In above:
function DataToHex(InData: Pointer; ByteLength: Integer; UseUpperCase: Boolean = True): string;
is in cnvcl\Source\Crypto\CnNative.pas

from cnvcl.

sxbug avatar sxbug commented on August 15, 2024

Thank you for your guidance。

I misunderstand at first. Now I also want to know which function could convert # $41 48 00 00 to 12.5 , hex-->single。

Happy Chinese new year!

from cnvcl.

shanzhashu avatar shanzhashu commented on August 15, 2024

There's also a function HexToData in CnNative.pas

Note:

  1. Space Chars in String should be removed before calling this function.
  2. Notice the BigEndian/Little Endian byte order after conversion.

from cnvcl.

sxbug avatar sxbug commented on August 15, 2024

These compoments is very good, but there are a few documents。Thanks

from cnvcl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.