Questions tagged as 'float'

1
answer

What is the maximum number of decimal places allowed in the float in PHP?

I was using Psysh to do tests with float numbers. I noticed that after a certain amount, it begins to limit the decimal places. Example: $float = 1.1234567891011121314 echo $float; // 1.1234567891011 Why is this happening?...
asked by 23.06.2016 / 21:00
1
answer

How to divide two variables properly?

In the code below I try to divide the values, but I end up getting a completely wrong answer from the calculation: nota1 = input ("Digite a nota 1: ") nota12 = input ("Digite a nota 1: ") nota2 = input ("Digite a nota 2: ") nota22 = input ("D...
asked by 22.02.2017 / 23:01
2
answers

Unexpected result

I want to divide two integers and result in a floating point value. The following code works normally: #include <stdio.h> float divInts(int x, int y) { return((float)x/y); } void main() { printf("%f",divInts(50,3)); } But...
asked by 07.09.2018 / 21:10
2
answers

How to pass a float without loss of value to an integer?

I have a float variable that can contain any number in it, I need to test if it fits an integer without losing values. I thought about using some test to see if the numbers after the comma are 0's or not. Does anyone know how?     
asked by 17.07.2017 / 22:50
2
answers

Decrease the precision of the float in Javascript?

How to decrease the decimal places of a float number in javascript? For example, I want 3.3333333333 to become 3.34 . What is the simplest way to do this in javascript ? I've tried functions like Math.ceil , but...
asked by 09.06.2015 / 19:34
1
answer

Float to Byte Array Conversion

How can I be converting from float or integer (if possible) to a byte array in Java. Let's say: float x=180 Theoretically you would need to create 1 array of bytes with 2 positions. Is there any way to 'automate' this?     
asked by 17.08.2017 / 21:01
1
answer

Error in variable value

I have the following doubt, I have to add a set of values that are set to string's , so I had to convert to float , I used the function str_replace() , except that when testing the variable with var_dump and perform the...
asked by 07.05.2015 / 03:53
1
answer

How can I print the fifth part of a real number?

How could I print the fifth (index 4 from the dot) part of a real number without using libraries or a "complex" code for opening chapters. Make a program that reads a real number, and print the fifth part of that number.
asked by 13.10.2017 / 14:00
1
answer

Javascript function with NaN error

This function is returning error: NaN, to convert back to text. function floatToMoneyText(value) { var text = (value < 1 ? "0" : " ") + Math.floor(value * 100); text = "R$ " + text; return text.substr(0,...
asked by 08.06.2016 / 04:03
2
answers

Using float to check for overflow in unsigned long int

Hello, how are you? Please review this code: #define max 4294967295 unsigned long int collatz(unsigned long int n, unsigned long int passos, float *maiorN) { float overflow = 3 * n + 1; if (n == 1) return passos; else if (...
asked by 24.08.2018 / 22:14