floating-point-conversion Questions

4

Solved

I am a new bash learner. I want to print the result of an expression given as input having 3 digits after decimal point with rounding if needed. I can use the following code, but it does not round....

6

Solved

I'd like to convert a given float into its binary representation. I tried to write the float value into a MemoryStream, read this MemoryStream byte by byte and convert the bytes into their binary r...
Demonography asked 20/1, 2014 at 21:12

1

Solved

Simple question: Will the conversion from an int, say 100, to a double "round" up or down to the next double or will it always round to the nearest one (smallest delta)? e.g. for static_c...

6

Solved

I have a list of floats in Python and when I convert it into a string, I get the following [1883.95, 1878.3299999999999, 1869.4300000000001, 1863.4000000000001] These floats have 2 digits after th...

4

Solved

I have the following code snippet: package main import("fmt";"flag") func main() { var a = flag.Int("a",0,"divident") var b = flag.Int("b",1,"divisor") flag.Parse() fmt.Printf("%f",*a / *b ...
Pinfold asked 13/12, 2013 at 16:28

9

Solved

How can I convert a float value to char* in C language?
Eviscerate asked 7/6, 2010 at 10:44

5

Solved

I want to display a float with the entire integer part and up to two decimals for the fractional part, without trailing zeros. http://play.golang.org/p/mAdQl6erWX: // Desired output: // "1.9" //...
Celik asked 8/7, 2015 at 10:3

2

Solved

Why is AsDouble1 much more straightforward than AsDouble0? // AsDouble0(unsigned long): # @AsDouble0(unsigned long) // movq xmm1, rdi // punpckldq xmm1, xmmword ptr [rip + .LCPI0_0] # xmm1 = xmm1[0...
Ordzhonikidze asked 5/7, 2022 at 7:59

5

In Python I need to convert a bunch of floats into hexadecimal. It needs to be zero padded (for instance, 0x00000010 instead of 0x10). Just like http://gregstoll.dyndns.org/~gregstoll/floattohex/ d...
Plater asked 13/5, 2014 at 6:32

6

Solved

I want to implement the equivalent of C's uint-to-double cast in the GHC Haskell compiler. We already implement int-to-double using FILD or CVTSI2SD. Is there unsigned versions of these operations ...
Wearable asked 5/12, 2012 at 23:9

1

When compile(x86-64 gcc 11.2 with -O2) the code below: double foo(unsigned int x) { return x/2.5; } double zoo(int x) { return x/2.5; } int main(){ return 0; } I got the assembly like ...
Drosophila asked 18/9, 2021 at 6:46

3

Solved

I need to make use of numbers coming from another system that are 128-bit (quadruple-precision) floating point numbers in java. Considering that there is no equivalent type in java, I would like t...
Ruddy asked 10/1, 2014 at 18:4

4

Solved

I have got a float variable that I need to send through a CAN protocol. To do so, this float of 32 bits must be cut in 4 uint8_t variables. I have absolutely no idea of how to do. I was first thin...
Decahedron asked 19/8, 2014 at 14:48

9

Solved

Is there a way to round floating points to 2 points? E.g.: 3576.7675745342556 becomes 3576.76.
Quadric asked 1/8, 2010 at 21:29

2

Solved

package main func main() { var n float64 = 6161047830682206209 println(uint64(n)) } The output will be: 6161047830682206208 It looks like that when float64 change to uint64, the fraction is...

2

Solved

According to https://en.cppreference.com/w/cpp/compiler_support/17, no major vendor yet supports floating point versions of std::to_chars and std::from_chars. I understand that correctly formatting...
Vase asked 6/9, 2019 at 16:9

2

Solved

Is it possible to perform half-precision floating-point arithmetic on Intel chips? I know how to load/store/convert half-precision floating-point numbers [1] but I do not know how to add/multiply ...

1

Solved

FJCVTZS is "Floating-point Javascript Convert to Signed fixed-point, rounding toward Zero". It is supported in Arm v8.3-A chips and later. Which is odd, because you don't expect to see Ja...

4

Solved

Could someone explain this weird looking output on a 32 bit machine? #include <stdio.h> int main() { printf("16777217 as float is %.1f\n",(float)16777217); printf("16777219 as float is %....
Onomatopoeia asked 13/5, 2018 at 18:48

4

I'm new to the whole coding thing...so here goes. Just trying to write a simple number guess game, but also do input validation. So that only integers are accepted as input. I've figured out ...
Halfassed asked 20/11, 2014 at 20:11

3

Solved

I'm using a front-end of Lua which is unfortunately outdated, so I'm stuck with version 5.1 here, meaning the bit32 library is out of reach (which I probably could have used to convert this). So I...
Bimetallic asked 19/9, 2013 at 4:55

2

Solved

I'm using float 24 bit to store a floating point value in a compiler MRK III from NXP. It stores the 24 bit float value as 3 byte Hex in Data memory. Now when I'm using IEEE 754 float point conver...

3

Solved

I am trying to calculate p1=(1/1)*(1/2)*...*(1/n) but something is wrong and the printf gives me 0.000...0 #include <stdio.h> int main(void) { int i,num; float p3; do { printf (...
Forgetful asked 11/11, 2012 at 12:19

6

My code reads an RGB image, processing it to produce floating-point results. How can I write these values as an image, maintaining these floating-point values, in Matlab 7.6.0 (R2008a)?

2

Solved

Supplying a float value of 37.35 I am getting a string of 37.3 Here is my code. DecimalFormat format = new DecimalFormat(".0"); format.setRoundingMode(RoundingMode.HALF_UP); return format.format(...
Brute asked 23/2, 2017 at 18:21

© 2022 - 2024 — McMap. All rights reserved.