Answers for "float numbers\"

4

css float property

/* 
  Nowadays with flex and grid, float has no chance to be putted inside your code
  But just for the knowledge of using this property.
  ===========================NOTICE===========================
    you should use the 'clear' CSS property after the div that has the float prop 
  ===========================NOTICE===========================
*/
.div-1{
  float: left;
  width: 50%;
  background-color: #f00;
}
/* 
  after applying float i used clear: both
  try this code and remove the clear property and see what will be happened
*/
.clear-float{
  clear: both;
}
.div-2{
  float: left;
  width: 50%;
  background-color: #00f;
}
.clear-float{
  clear: both;
}
/* div-1 and div-2 will now be at the side of each other*/
/*
  ==========HTML Layout==========
  <div class="div-1">DIV 1</div>
  <div class="clear-float"></div>
  <div class="div-2">DIV 2</div>
  <div class="clear-float"></div>
*/
Posted by: Guest on June-12-2021
0

float

I want to print a float value which has 2 integer digits and 6 decimal digits after the comma. If I just use printf("%f", myFloat) I'm getting a truncated value.

I don't know if this always happens in C, or it's just because I'm using C for microcontrollers (CCS to be exact), but at the reference it tells that %f get just that: a truncated float.

If my float is 44.556677, I'm printing out "44.55", only the first two decimal digits.
Posted by: Guest on November-14-2020

Browse Popular Code Answers by Language