Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

115
Visualizações
How do you add 0.1 to a setvalue?

I have a variable ekeys, which basically creates a ruler down a page and sets a depth (elevation) value down the ruler compared to the 0 value.

i.e. the ruler will show 1 metre depth. If surface elevation is set to 4.2 metres, then 1 metre down the corresponding elevation will be 4.2 metres minus 1 metre - which = 3.2 metres. For some reason it is 0.1 m out (i.e. showing 3.1 metres instead of 3.2 metres).

Is there an easy way to change this code: setValue(eKeys[k])

to add 0.1?

i.e. .setValue(eKeys[k]+0.1) <--- this does not work (it shows a value of 30.2 instead of 3.2).

var rKeys = Object.keys(mergeThisRows);
  var eKeys = Object.keys(mergeThisRowsE);
  for (k = 0; k < rKeys.length; k++) {
    shTemplate.getRange(mergeThisRows[rKeys[k]] + STARTT_ROW - 1, DEPTH_COL + 1, 2, 1).breakApart().merge().setValue(rKeys[k]).setFontColor("black").setFontSize(6).setVerticalAlignment("top").setHorizontalAlignment("right");
    shTemplate.getRange(mergeThisRows[rKeys[k]] + STARTT_ROW - 1, DEPTH_COL + 1, 2, 1).setBorder(true, null, null, null, null, null, '#000000', SpreadsheetApp.BorderStyle.SOLID);;
    if (eKeys[k] != undefined) {
      shTemplate.getRange(mergeThisRowsE[eKeys[k]] + STARTT_ROW - 1, ELEVATION_COL + 1, 2, 1).breakApart().merge().setValue(eKeys[k]).setNumberFormat("0.0").setFontColor("black").setFontSize(6).setVerticalAlignment("top").setHorizontalAlignment("right");
      shTemplate.getRange(mergeThisRowsE[eKeys[k]] + STARTT_ROW - 1, ELEVATION_COL + 1, 2, 1).setBorder(true, null, null, null, null, null, '#000000', SpreadsheetApp.BorderStyle.SOLID);
    }
  }
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I'd propose to use the unary + operator to convert the string into a number:

setValue(+eKeys[k] + 0.2)

Reference

  • Unary plus (+)
about 4 years ago · Juan Pablo Isaza Relatório

0

setValue(parseInt(eKeys[k])+0.2)
-> 3.2
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda