-4

it seems hexadecimal numbers are good for c/c++/rust iot programming. Below are images in favour of hexadecimal numbers . heksbin numbers from one to vnti

heksbin numbers from one to vnti vn to tuti

I am looking for rust compiler in which hexadecimal is default base for integers float . ascii_510(5+5=10) --> hskii_810(8+8=10=4X4)

int10 a = 484; B // above line in ascii_510 rust will look as : int16 a = 0x484B ; so kindly provide hint how & which files in rust source be changed. hskii_810

1 Answers1

1

You can use hexadecimal numbers by prepending a 0x to your integer:

fn main() {
    println!("{}", 0x44);
}

Playground.

Using hexadecimal makes no sense with floats, since you'd either want to set the bits (which should be done using special functions, see this question) or write hexadecimal numbers with a fractional point, like F3.2A.

The latter is not supported in the compiler, although there is most likely some crate out there which supports it. If there isn't the best way to do so is to use a proc macro to calculate the decimal equivalent and to evaluate to the correct number.

Optimistic Peach
  • 3,862
  • 2
  • 18
  • 29
  • yes it seems function : string atoh(ascii_510_string) ; is good option. – vimal kumar Sep 22 '20 at 00:24
  • There is no built in method to convert hexadecimal numbers with a decimal place to a floating point number, and it is unlikely to be added to the compiler. I'd run it through an RFC if it were really important though, and then it could be decided based on what the community would want. However, using a proc macro would make a lot of sense for this, it'd be relatively easy to calculate the number based on the literal passed in and then spit out the numeric value. – Optimistic Peach Sep 22 '20 at 00:27